Home >Backend Development >PHP Tutorial >php多维数组合并成一个数组,该如何处理

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

WBOY
WBOYOriginal
2016-06-13 12:09:031086browse

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); 
Array<br />(<br />    [0] => 1<br />    [1] => 2<br />)<br /><br />

------解决思路----------------------
$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);

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