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

WBOY
Release: 2016-06-13 11:52:21
Original
957 people have browsed it

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 />
Copy after login

------解决方案--------------------
这个意思?
$a = array('a', 'b' , 'c' , 'd', 'e');<br />$b = $b = array('a', 'c', 'd');<br />print_r(array_intersect($a, $b));
Copy after login
Array
(
    [0] => a
    [2] => c
    [3] => d
)

Related labels:
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!