Skip to content

Instantly share code, notes, and snippets.

@qutek
Created December 29, 2017 03:21
Show Gist options
  • Save qutek/e7ac01669bd7ccc18c44b58828014aaf to your computer and use it in GitHub Desktop.
Save qutek/e7ac01669bd7ccc18c44b58828014aaf to your computer and use it in GitHub Desktop.
[PHP Convert multidimensional object to array] #php #array
<?php
/**
* Convert object to array
* @param [type] $obj [description]
* @return [type] [description]
*/
function obj_to_array($obj) {
if(!is_array($obj) && !is_object($obj))
return $obj;
if(is_object($obj))
$obj = get_object_vars($obj);
return array_map(__FUNCTION__, $obj);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment