Skip to content

Instantly share code, notes, and snippets.

@piercemoore
Last active October 12, 2015 09:18
Show Gist options
  • Select an option

  • Save piercemoore/4005418 to your computer and use it in GitHub Desktop.

Select an option

Save piercemoore/4005418 to your computer and use it in GitHub Desktop.
Recurse through an object and display formatted contents
<?php
private function dig( $obj , $level = 0 ) {
$return = "";
$tabs = str_repeat( "\t" , $level );
foreach( $obj as $k => $v ) {
if( self::keyed( $v ) ) {
$return .= $tabs . "$k object: \n";
$return .= self::dig( $v , $level + 1 );
} else {
$return .= $tabs . "$k -- $v \n";
}
}
return $return;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment