0
array (0 => stdClass::__set_state(array(
 'information' => 
stdClass::__set_state(array(
   'url' => 'https://www.website.com/in/thing-again-3424/',
   'email' => NULL,
   'picture' => 'https://234324.234324.com/mpr/mpr/shrinknp_400_400/234234.jpg',
   'fullname' => 'James Smith',
   'headline' => 'Senior',
   'company' => 'Boots Ltd',
   'school' => 'Fake University',
   'location' => 'Fake, United Kingdom',
   'summary' => 'Did some stuff',
   'emailScore' => 0,
)),
 'experiences' => 
array (
  0 => 
  stdClass::__set_state(array(
     'href' => '/thebest/numbers/',
     'role' => 'Programmer',
     'companyName' => 'Boots Ltd',
     'dateRange' => 'Mar 2017 – Present',
     'location' => 'london',

This data was an object in my js and it was passed to my php server as a form, I have decoded it with $data = json_decode($request->profile);

The above structure is what it has come out as

My question is how i would grab a single element, such as picture Something along the lines of

$data->information->picture

Reminder, this is on laravel.

Jeremy
  • 151
  • 1
  • 1
  • 10
  • 1
    add `true` parameter to your `json_decode` http://php.net/manual/en/function.json-decode.php – Edwin Sep 13 '17 at 11:01
  • @Edwin this decodes json to array. – u_mulder Sep 13 '17 at 11:03
  • use second argument of `json_decode` to `true` it returns array instead of objest..so you can easily get first element of array by its index value – Vipul L. Sep 13 '17 at 11:07
  • you can use toArray(); – Ashish Patel Sep 13 '17 at 11:34
  • @u_mulder yes it does, then he can use the values from the arrays. If he wants to serialize/deserialize then he should flow https://stackoverflow.com/questions/8641889/how-to-use-php-serialize-and-unserialize and put the question right – Edwin Sep 13 '17 at 11:53

0 Answers0