I have a string that looks like this:
[
   {
      "id":"2",
      "price":"39.99",
      "timeStamp":"1506264307167",
      "quantity":"1",
      "colours":"Green",
      "pid":"234234234"
   },
   {
      "id":"2",
      "price":"39.99",
      "timeStamp":"1506264311757",
      "quantity":"1",
      "colours":"Blue",
      "pid":"234234234"
   }
]
I need to get the id from this JSON string using PHP.
So I tried this:
$details = '[
       {
          "id":"2",
          "price":"39.99",
          "timeStamp":"1506264307167",
          "quantity":"1",
          "colours":"Green",
          "pid":"234234234"
       },
       {
          "id":"2",
          "price":"39.99",
          "timeStamp":"1506264311757",
          "quantity":"1",
          "colours":"Blue",
          "pid":"234234234"
       }
    ]';
$details = json_encode($details, true);
$array = json_decode($details, true);
$oid = $array['id'];
echo $oid;
The code above is in a while loop so the echo $oid should echo the id 
multiple times.
anyway, the code above only prints this:
[
[
and when i look in the error log, i see this error:
PHP Warning:  Illegal string offset 'id'
Could someone please advice on this issue?
Thanks in advance.
 
     
     
    