Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
recursively cast a PHP object to array
This function saved my life.
found on:
by: crvandyke
It takes an object, and when all else if/else/recursive functions fail to convert the object into an associative array, this one goes for the kill. Who would'a thunk it?!
$array = json_decode(json_encode($object), true);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment