Skip to content

Instantly share code, notes, and snippets.

@Avi-E-Koenig
Created September 27, 2021 11:35
Show Gist options
  • Save Avi-E-Koenig/43fbda11eb4a5ab448e0ec2d2cf327fe to your computer and use it in GitHub Desktop.
Save Avi-E-Koenig/43fbda11eb4a5ab448e0ec2d2cf327fe to your computer and use it in GitHub Desktop.
print an object in php to screen
function printAll($spaces = 0, $payload)
{
$currentIndentation = str_repeat(" ", $spaces);
if (is_string($payload)) {
echo "&nbsp;$payload<br/>";
}
if (is_array($payload)) {
foreach ($payload as $key => $value) {
echo "<br/> $currentIndentation $key: ";
printAll($spaces++, $value);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment