I have the following:
Array ( [0] => Array ( [0] => Array ( [value] => 150109 [format] => [safe_value] => 150109 ) ) )
I need to get the value "150109", but how on earth do I accomplish that?
Top level:
print_r($data);
// Output: Array ( [0] => Array ( [0] => Array ( [value] => 150109 [format] => [safe_value] => 150109 ) ) )
Outmost element:
print_r($data[0]);
// Output: Array ( [0] => Array ( [value] => 150109 [format] => [safe_value] => 150109 ) )
Next level:
print_r($data[0][0]);
// Output: Array ( [value] => 150109 [format] => [safe_value] => 150109 )
The final value
echo $data[0][0]['value'];
// Output: 150109
Accessing each layer of values this way makes it easier to figure out how to get to your desired value. After a while this becomes more obvious.
您可以在多维数组上连续使用数组的获取值:
$value = $array[0][0]["value"];
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.