1

I tried using data_get() function, But it doesn't return me anything.

Can any one help me to access data array from the below object in laravel??

Any information regarding this would be appreciated. Thank You!!

$data = data_get($object,'data');

 $object = {
  "success": true,
  "message": "Something....",
  "data": [
   
       {
          "id": 9,
          "name": "name1"
       },
       {
          "id": 10,
          "name": "name2"
       }

   ]
}
susmita rai
  • 39
  • 2
  • 20

2 Answers2

2

You can convert the json object into an array using json_decode().

$newObject = json_decode($object, true);

From here, you can simply access it like

$data = $newObject['data'];

$message = $newObject['message'];

Digvijay
  • 7,836
  • 3
  • 32
  • 53
1

$data = json_decode($object, true); $data->message;