How to use a returned PHP array inside an array itself? -
i create php array, of elements replaced elements of array returned function. example, create following array:
$aarray = array( 0x01, 0x10, foo(1234), 0x03, foo(445), ... )
here, foo
function returning simple php array. is, of course, like
( [0] => 1 [1] => 16 [2] => array ( [1] => 2 [2] => 4 ) [3] => 03 [4] => array ....
but want include returned values function directly array, create like: ( [0] => 1 [1] => 16 [2] => 2 [3] => 4 [4] => 03 [5] => 3 ....
is possible in simple way, without having construct array array_merge
?
p.s: above example not working example, showing want do. content of function foo
irrelevant.
this closest thing can match need
$aarray = array_flat( 0x01, 0x10, foo(1234), 0x03, foo(445) );
and here code array_flat
.
function array_flat() { $array = func_get_args() $result = array(); foreach ($array $value) { is_array($value) || $value = array($value); foreach ($value $dvalue) { $result[] = $dvalue; } } return $result; }
Comments
Post a Comment