php多维数组合并成一个数组,该如何处理

WBOY
Release: 2016-06-13 12:09:03
Original
1054 people have browsed it

php多维数组合并成一个数组
Array ( [0] => Array ( [id] => 1 ) [1] => Array ( [id] => 2 ) ) 

------解决思路----------------------
由于你没有给出你需要的格式,所以只能举一例

$a = Array(<br />  Array( 'id' => 1 ),<br />  Array( 'id' => 2 )<br />);<br /><br />$a = array_map('current', $a);<br />print_r($a); 
Copy after login
Array<br />(<br />    [0] => 1<br />    [1] => 2<br />)<br /><br />
Copy after login

------解决思路----------------------
$a = Array(<br />  Array( 'id' => 1 ),<br />  Array( 'id' => 2 )<br />);<br />$ar = array();<br />foreach($a as $v) $ar[] = $v['id'];<br />print_r($ar);
Copy after login

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