I'm trying to create variables from a multidimensional array using foreach, but cannot access the nested arrays.
I tried using foreach again within my current foreach command, but I think something in the format of the array will not let me do this.
PHP:
$response = curl_exec($cURL);
$result = json_decode($response, true);
$someArray = $result;
foreach ($someArray as $key => $value) {;
}
curl_close($cURL);
print $value["registration"];
print $value["make"];
print $value["model"];
print $value["fuelType"];
print $value["primaryColour"];
This is exactly how I receive the array. I can create variables for registration, make, model, firstUsedDate, fuelType and primaryColour.
array(
[0] => array(
[registration] => DU11LVA
[make] => MINI
[model] => MINI(R57)
[firstUsedDate] => 2011.03.05
[fuelType] => Diesel
[primaryColour] => White
[motTests] => array(
[0] => array(
[completedDate] => 2018.04.1116:00:30
[testResult] => PASSED
[expiryDate] => 2019.04.10
[odometerValue] => 45283
[odometerUnit] => mi
[motTestNumber] => 138359719457
[rfrAndComments] => array(
[0] => array(
[text] => Nearside Front Road wheel with a slightly distorted bead rim INSIDE (4.2.A.1a)
[type] => ADVISORY)))
[1] => array(
[completedDate] => 2018.04.1110:22:54
[testResult] => FAILED
[odometerValue] => 45283
[odometerUnit] => mi
[motTestNumber] => 652014545840
[rfrAndComments] => array(
[0] => array(
[text] => Nearside Front Road wheel with a slightly distorted bead rim INSIDE (4.2.A.1a)
[type] => ADVISORY)
[1] => array(
[text] => Nearside Front Shock absorber has a serious fluid leak (2.7.3)
[type] => FAIL)))
[2] => array(
[completedDate] => 2017.04.0610:27:08
[testResult] => PASSED
[expiryDate] => 2018.04.08
[odometerValue] => 37579
[odometerUnit] => mi
[motTestNumber] => 605834707501
[rfrAndComments] => array())
I'm trying to get the expiryDate and odometerValue.