You can use following code snippet to get value of mentioned keys-
<?php
$str = '{
"articles": {
"1": {"discription":"Transport", "tax":"21", "price":"234"
},
"2": {"discription":"Opslag", "tax":"19", "price":"19"}
}
}';
//convert json to array
$jsonToArray = json_decode($str, true);
foreach ($jsonToArray['articles'] as $value) {
echo $value['discription'] . ' ' . $value['tax'] . ' ' . $value['price'] . PHP_EOL;
}
if you want to access those keys with object then you can proceed with following code snippet-
<?php
$str = '{
"articles": {
"1": {"discription":"Transport", "tax":"21", "price":"234"
},
"2": {"discription":"Opslag", "tax":"19", "price":"19"}
}
}';
//convert json to object
$jsonToObject = json_decode($str);
foreach ($jsonToObject->articles as $value) {
echo $value->discription . ' ' . $value->tax . ' ' . $value->price . PHP_EOL;
}
You are free to make changes in the echo statement that suits your requirement.
Checkout my all the technical post.