php - How to merge array in one array under foreach loop -
i have array
want merge under foreach
loop please provide solution how can it.
array ( [0] => array ( [id] => 377556 [name] => 8 ball pool ios app - * ) ) array ( [0] => array ( [id] => 377555 [name] => test data ) )
i want below result please provide solution how can merge data in 1 array .
array ( [0] => array ( [id] => 377556 [name] => 8 ball pool ios app - * ) [1] => array ( [id] => 377555 [name] => test data ) )
<?php $array1=array ( 0 => array ( "id" => 377556, "name" => "8 ball pool ios app - *" ) ); $array2=array ( 0 => array ( "id" => 377555, "name" => "test data" ) ); $newarray=array($array1,$array2); $result=array(); foreach($newarray $value) { $result=array_merge($result,$value); } print_r($result);
output:
array ( [0] => array ( [id] => 377556 [name] => 8 ball pool ios app - * ) [1] => array ( [id] => 377555 [name] => test data ) )
Comments
Post a Comment