Skip to content

Instantly share code, notes, and snippets.

@brandonsavage
Created October 11, 2016 14:07
Show Gist options
  • Save brandonsavage/1fcf02db3fb09a9fcb48fc2d60a468ab to your computer and use it in GitHub Desktop.
Save brandonsavage/1fcf02db3fb09a9fcb48fc2d60a468ab to your computer and use it in GitHub Desktop.
<?php
$class = new stdClass();
$class->abc = 'def';
$class->ghi = 'jkcl';
$classDetails = (array)$class;
list($abc, $def) = $classDetails;
var_dump($abc, $def);
@Hasnayeen
Copy link

list is for index based array not associative array. Either use extract or remove the key from the array
extract($classDetails);
Or
list($abc, $def) = array_values($classDetails);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment