using php how to get array result into below way,
Array
(
[3] => Array
(
[15] => 15
[16] => 16
[17] => 17
[18] => 18
[19] => 19
)
)
how to convert above array into below format,
Array
(
[0] => 15
[1] => 16
[2] => 17
[3] => 18
[4] => 19
)
array_values()
is your friend;
Presuming your array exists in a variable called $array
;
$newArray = array_values($array[3]);
you should use RecursiveArrayIterator to remove parent array
$arr = new RecursiveIteratorIterator(new RecursiveArrayIterator($multidimensional_array));
$new_arr = iterator_to_array($arr, false);
try this, if you have more than one sub-array, it will work.
$arr = array(3 =>
array
(
15 => 15,
16 => 16,
17 => 17,
18 => 18,
19 => 19
)
);
$new = array();
foreach ($arr as $v){
$new = array_merge($new , array_values($v)) ;
}
echo "<pre>"; print_r($new);