Skip to content

Instantly share code, notes, and snippets.

@andyg1
Created August 18, 2023 15:06
Show Gist options
  • Save andyg1/eed651e27cd7484fd04aa4f0e02e1e8f to your computer and use it in GitHub Desktop.
Save andyg1/eed651e27cd7484fd04aa4f0e02e1e8f to your computer and use it in GitHub Desktop.
<?php
function objectToArray($object) {
$json = json_encode($object);
return json_decode($json, true);
}
// or, in one line
$nestedArray = json_decode(json_encode($object), true);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment