PHP获取数组某几列的键值

WBOY
Release: 2016-06-23 14:00:17
Original
1244 people have browsed it

比如$a = array(a,b,c,d,e);想要获取$b = array(a,c,d)怎样获取


回复讨论(解决方案)

最简单的

$a = array(a,b,c,d,e);$b = array($a[0], $a[2], $a[3]);
Copy after login
Copy after login

最简单的

$a = array(a,b,c,d,e);$b = array($a[0], $a[2], $a[3]);
Copy after login
Copy after login

$a是多维数组,这样做的话就是获取维数了,并没有获取键的序列的值

这个意思?

$a = array('a', 'b' , 'c' , 'd', 'e');$b = $b = array('a', 'c', 'd');print_r(array_intersect($a, $b));
Copy after login
Array
(
    [0] => a
    [2] => c
    [3] => d
)

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!