Home  >  Article  >  Backend Development  >  PHP获取数组某几列的键值

PHP获取数组某几列的键值

WBOY
WBOYOriginal
2016-06-23 14:00:171245browse

比如$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]);

最简单的

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

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

这个意思?

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

Statement:
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