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"
       }

   ]
}
2
  • you can check it : stackoverflow.com/questions/55185531/… Commented Jul 12, 2020 at 6:24
  • That doesn't look like an object. That doesn't even look like PHP Commented Jul 12, 2020 at 6:25

2 Answers 2

3

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'];

Sign up to request clarification or add additional context in comments.

Comments

1

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.