<?php
$data = array(
array (
'text' => 'paris',
'nodes' => array(
array(
'text' => 'paris',
'nodes' => array(
'text' => 'so.png',
),
),
),
),
array(
'text' => 'charl',
'nodes' => array(
array(
'text' => 'charl',
'nodes' => array(
'text' => 'so.png',
),
),
),
)
);
for($i = 0; $i <= count($data) -1; $i++) {
$data[$i]['nodes'] = array_map(function($node) {
return array_values($node);
}, $data[$i]['nodes']);
}
var_dump($data);
- Output for 5.6.38, 7.0.33, 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.31, 8.2.0 - 8.2.27, 8.3.0 - 8.3.15, 8.4.1 - 8.4.2
- array(2) {
[0]=>
array(2) {
["text"]=>
string(5) "paris"
["nodes"]=>
array(1) {
[0]=>
array(2) {
[0]=>
string(5) "paris"
[1]=>
array(1) {
["text"]=>
string(6) "so.png"
}
}
}
}
[1]=>
array(2) {
["text"]=>
string(5) "charl"
["nodes"]=>
array(1) {
[0]=>
array(2) {
[0]=>
string(5) "charl"
[1]=>
array(1) {
["text"]=>
string(6) "so.png"
}
}
}
}
}
preferences:
143.89 ms | 409 KiB | 5 Q