- json_decode: documentation ( source)
<?php
$string = '[{
"errorcode": "0",
"xml": {
"seat-map": {
"lower-deck": {
"column": [
{
"$": {
"id": "1"
},
"row": [
{
"$": {
"id": "1"
},
"seat": {
"$": {
"number": "3",
"status": "0"
}
}
},
{
"$": {
"id": "2"
},
"seat": {
"$": {
"number": "6",
"status": "0"
}
}
},
{
"$": {
"id": "3"
},
"seat": {
"$": {
"number": "9",
"status": "0"
}
}
},
{
"$": {
"id": "4"
},
"seat": {
"$": {
"number": "12",
"status": "0"
}
}
},
{
"$": {
"id": "5"
},
"seat": {
"$": {
"number": "15",
"status": "0"
}
}
},
{
"$": {
"id": "6"
},
"seat": {
"$": {
"number": "18",
"status": "0"
}
}
},
{
"$": {
"id": "7"
},
"seat": {
"$": {
"number": "21",
"status": "0"
}
}
},
{
"$": {
"id": "8"
},
"seat": {
"$": {
"number": "24",
"status": "0"
}
}
},
{
"$": {
"id": "9"
},
"seat": {
"$": {
"number": "27",
"status": "0"
}
}
},
{
"$": {
"id": "10"
},
"seat": {
"$": {
"number": "#",
"status": "blank"
}
}
},
{
"$": {
"id": "11"
},
"seat": {
"$": {
"number": "#",
"status": "blank"
}
}
},
{
"$": {
"id": "12"
},
"seat": {
"$": {
"number": "#",
"status": "blank"
}
}
}
]
},
{
"$": {
"id": "2"
},
"row": [
{
"$": {
"id": "1"
},
"seat": {
"$": {
"number": "2",
"status": "0"
}
}
},
{
"$": {
"id": "2"
},
"seat": {
"$": {
"number": "5",
"status": "0"
}
}
},
{
"$": {
"id": "3"
},
"seat": {
"$": {
"number": "8",
"status": "0"
}
}
},
{
"$": {
"id": "4"
},
"seat": {
"$": {
"number": "11",
"status": "0"
}
}
},
{
"$": {
"id": "5"
},
"seat": {
"$": {
"number": "14",
"status": "0"
}
}
},
{
"$": {
"id": "6"
},
"seat": {
"$": {
"number": "17",
"status": "0"
}
}
},
{
"$": {
"id": "7"
},
"seat": {
"$": {
"number": "20",
"status": "0"
}
}
},
{
"$": {
"id": "8"
},
"seat": {
"$": {
"number": "23",
"status": "0"
}
}
},
{
"$": {
"id": "9"
},
"seat": {
"$": {
"number": "26",
"status": "0"
}
}
},
{
"$": {
"id": "10"
},
"seat": {
"$": {
"number": "#",
"status": "blank"
}
}
},
{
"$": {
"id": "11"
},
"seat": {
"$": {
"number": "#",
"status": "blank"
}
}
},
{
"$": {
"id": "12"
},
"seat": {
"$": {
"number": "#",
"status": "blank"
}
}
}
]
},
{
"$": {
"id": "3"
},
"row": [
{
"$": {
"id": "1"
},
"seat": {
"$": {
"number": "#",
"status": "blank"
}
}
},
{
"$": {
"id": "2"
},
"seat": {
"$": {
"number": "#",
"status": "blank"
}
}
},
{
"$": {
"id": "3"
},
"seat": {
"$": {
"number": "#",
"status": "blank"
}
}
},
{
"$": {
"id": "4"
},
"seat": {
"$": {
"number": "#",
"status": "blank"
}
}
},
{
"$": {
"id": "5"
},
"seat": {
"$": {
"number": "#",
"status": "blank"
}
}
},
{
"$": {
"id": "6"
},
"seat": {
"$": {
"number": "#",
"status": "blank"
}
}
},
{
"$": {
"id": "7"
},
"seat": {
"$": {
"number": "#",
"status": "blank"
}
}
},
{
"$": {
"id": "8"
},
"seat": {
"$": {
"number": "#",
"status": "blank"
}
}
},
{
"$": {
"id": "9"
},
"seat": {
"$": {
"number": "#",
"status": "blank"
}
}
},
{
"$": {
"id": "10"
},
"seat": {
"$": {
"number": "#",
"status": "blank"
}
}
},
{
"$": {
"id": "11"
},
"seat": {
"$": {
"number": "#",
"status": "blank"
}
}
},
{
"$": {
"id": "12"
},
"seat": {
"$": {
"number": "#",
"status": "blank"
}
}
}
]
},
{
"$": {
"id": "4"
},
"row": [
{
"$": {
"id": "1"
},
"seat": {
"$": {
"number": "1",
"status": "0"
}
}
},
{
"$": {
"id": "2"
},
"seat": {
"$": {
"number": "4",
"status": "0"
}
}
},
{
"$": {
"id": "3"
},
"seat": {
"$": {
"number": "7",
"status": "0"
}
}
},
{
"$": {
"id": "4"
},
"seat": {
"$": {
"number": "10",
"status": "0"
}
}
},
{
"$": {
"id": "5"
},
"seat": {
"$": {
"number": "13",
"status": "0"
}
}
},
{
"$": {
"id": "6"
},
"seat": {
"$": {
"number": "16",
"status": "0"
}
}
},
{
"$": {
"id": "7"
},
"seat": {
"$": {
"number": "19",
"status": "0"
}
}
},
{
"$": {
"id": "8"
},
"seat": {
"$": {
"number": "22",
"status": "0"
}
}
},
{
"$": {
"id": "9"
},
"seat": {
"$": {
"number": "25",
"status": "0"
}
}
},
{
"$": {
"id": "10"
},
"seat": {
"$": {
"number": "#",
"status": "blank"
}
}
},
{
"$": {
"id": "11"
},
"seat": {
"$": {
"number": "#",
"status": "blank"
}
}
},
{
"$": {
"id": "12"
},
"seat": {
"$": {
"number": "#",
"status": "blank"
}
}
}
]
}
]
}
}
}
}]';
$json = json_decode($string, true);
foreach($json AS $array) {
foreach($array AS $key => $value) {
echo $key . " : " . $value . "\n";
}
}