I am trying to get a data from my own API using PHP \
My PHP code :
$cart = json_decode(file_get_contents("php://input",true));
foreach ($cart->thoubss as $a){
echo($a['0']); // trying to get the first element in the array (4) in the first iteration and then (3) in the second iteration
echo($a['1']); // trying to get the first element in the array (5) in the first iteration and then (3) in the second iteration
}
My JSON input :
{"thoubss":"{'0': [4, 5], '1': [5, 3]}"}
I am getting
PHP Warning: Invalid argument supplied for foreach()
print_r($cart) output
stdClass Object
(
[thoubss
] => {'0': [
4,
5
], '1': [
5,
3
]
}
)