As long as you are familiar with this column, the PHP array operation is basically no problem. Directly on the code (from 1-D assembly to 4-D array):
<?php
Header ("content-type:text/html; Charset=utf-8 ");
$gold =[];
$m _array=array ();
$all _gold=array ();
1-D Arrays
$m _date1=array (
' Price ' = ' 279 ',
' Product ' = ' gold bar ',
' Shop ' = ' old Temple ',
);
$m _date2=array (
' Price ' = ' 322 ',
' Product ' = ' gold bar ',
' Shop ' = ' Lao Feng Xiang ',
);
$m _date3=array (
' Price ' = ' 299 ',
' Product ' = ' gold ',
' Shop ' = ' old Temple ',
);
$m _date4=array (
' Price ' = ' 300 ',
' Product ' = ' gold bar ',
' Shop ' = ' six blessing ',
);
$m _date5=array (
' Price ' = ' 299 ',
' Product ' = ' gold ',
' Shop ' = ' Lao Feng Xiang ',
);
Assemble a 2-D array
Array_push ($m _array, $m _date1, $m _date2, $m _date3, $m _date4, $m _date5);
Assemble a 3-D array;
for ($i =0; $i <count ($m _array); $i + +) {
if (array_key_exists ($m _array[$i [' Shop '], $gold)) {
echo "The array contains ' key ';
Array_push ($gold [$m _array[$i] [' Shop ']], $m _array[$i]);
}
else{
$gold [$m _array[$i] [' Shop ']][0]= $m _array[$i];
}
}
Defining a 3-D array
$pt = Array (
' Six blessings ' =
Array (
' Price ' = ' 310 ',
' Product ' = ' pt999 ',
' Shop ' = ' six blessing ',
),
' Lao Feng Xiang ' =
Array
Array (
' Price ' = ' 300 ',
' Product ' = ' pt995 ',
' Shop ' = ' Lao Feng Xiang ',
),
Array
' Price ' = ' pt ',
' Product ' = ' gold ',
' Shop ' = ' Lao Feng Xiang ',
)
)
);
Assemble into a 4-D array
$all _gold=array (
' pt ' = $pt,
' Gold ' = $gold
);
Var_dump ($all _gold);
As for traversing a 4-dimensional array, just keep nesting the foreach.
PHP four-dimension array, three-dimensional array encapsulation traversal