From a one-dimensional array multidimensional php?

Hi all.
There is a one-dimensional array array
Array
(
 [0] => size:0.68| time :15| path :/var/cache/bind/managed-keys.bind
 [1] => size:0.5| time :15| path :/var/cache/bind/managed-keys.bind.jnl
)

How do I turn in a multidimensional
Array
(
[0] =>
[size] => 0.68,
[time] => 15,
[path] => /var/cache/bind/managed-keys.bind
[1] => size:0.5| time :15| path :/var/cache/bind/managed-keys.bind.jnl
[size] => 0.15,
[time] => 15,
[path] => /var/cache/bind/managed-keys.bind.jnl
)

Doing this there follows:
// deduce all files
 exec("find / -type f", $out);
 // iterate all files
 foreach($out as $name){
 //get the file modification time
$vrema = 'get the time the changes file';
// create the array 
 $string[] = "size:".round(filesize($name)/1024,2)."| time :". $vrema ."| path :".$name ;
 // split the string for convenience
 $array2 = explode('|', $string);
 // next, form a multidimensional array
 foreach($array2 as $str) {
 list($key, $value) = explode(':', $str);
 $array1[$key] = $value;
}
}
And so deduce a multidimensional array to one string. 
print_r($array1);

How do I make right?
July 12th 19 at 17:16
2 answers
July 12th 19 at 17:18
Solution
And why did you form the first line?
// deduce all files
exec("find / -type f", $out);
// iterate all files
$itogovij_array = array();
foreach($out as $name){
 //get the file modification time
 $vrema = 'get the time the changes file';
// create the array
 $temp_array = array(
'size'=>round(filesize($name)/1024,2),
'time'=>$vrema,
'path'=>$name,
);
$itogovij_array[]=$temp_array;
}
July 12th 19 at 17:20
Solution
Is not it easier to write like that, without any divisions?
foreach($out as $name) {
 $array[] = [
 'size' => round(filesize($name)/1024,2),
...
];
}
Tried, just did not happen.
If only what I do wrong. - wiley_Torphy70 commented on July 12th 19 at 17:23
What is there in the trailer could go wrong? Unless you have an older PHP without support for a short record arrays, but this is simply solved by replacing [...] to array(...). Here is an example sandbox.onlinephpfunctions.com/code/a8159d1af9c594... - Gennaro_Dooley commented on July 12th 19 at 17:26
: Thanks! - wiley_Torphy70 commented on July 12th 19 at 17:29

Find more questions by tags PHPArrays