Skip to content

Instantly share code, notes, and snippets.

@ZellSnippets
Created February 11, 2014 07:45
Show Gist options
  • Save ZellSnippets/8930699 to your computer and use it in GitHub Desktop.
Save ZellSnippets/8930699 to your computer and use it in GitHub Desktop.
PHP: Recursively show all data of arrays
<?php
function show_data ($data) {
foreach ($data as $key => $value) {
echo '<ul style="margin-left: 20px">';
if (gettype($value) == 'array' ) {
echo '<li>' . $key . " : " . $value . '</li>';
echo '<ul style="margin-left: 20px">';
show_data($value);
echo '</ul>';
}
else {
echo '<li>' . $key . " : " . $value . '</li>';
}
echo '</ul>';
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment