Home >Backend Development >PHP Tutorial >PHP获取数组某几列的键值,该如何解决

PHP获取数组某几列的键值,该如何解决

WBOY
WBOYOriginal
2016-06-13 11:52:21997browse

PHP获取数组某几列的键值
比如$a = array(a,b,c,d,e);想要获取$b = array(a,c,d)怎样获取
------解决方案--------------------
最简单的

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

------解决方案--------------------
这个意思?
$a = array('a', 'b' , 'c' , 'd', 'e');<br />$b = $b = array('a', 'c', 'd');<br />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