Created
September 27, 2021 11:35
-
-
Save Avi-E-Koenig/43fbda11eb4a5ab448e0ec2d2cf327fe to your computer and use it in GitHub Desktop.
print an object in php to screen
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function printAll($spaces = 0, $payload) | |
{ | |
$currentIndentation = str_repeat(" ", $spaces); | |
if (is_string($payload)) { | |
echo " $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