Skip to content

Instantly share code, notes, and snippets.

@berliozd
Last active October 26, 2016 09:03
Show Gist options
  • Save berliozd/9094858a3489eced922c636b76d0172b to your computer and use it in GitHub Desktop.
Save berliozd/9094858a3489eced922c636b76d0172b to your computer and use it in GitHub Desktop.
<?php
/**
* Transform multi dimension object in multi dimension array
*
* @param $obj
* @return array
*/
private static function toArray($obj)
{
if (is_object($obj)) {
$obj = (array)$obj;
}
if (is_array($obj)) {
$new = array();
foreach ($obj as $key => $val) {
$new[$key] = self::toArray($val);
}
} else {
$new = $obj;
}
return $new;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment