Instantly share code, notes, and snippets.

Embed
What would you like to do?
Pretty output...
<?php
/**
* This function returns a nice output of any given type of data
*
* @param mixed $value Some value (variable, object, array, class, whatever)
*
* @return string
*/
function pre($value) {
return "<pre>" . print_r($value, 1) . "</pre>";
}
$MyArray = [
'string',
true,
'key' => 'value',
'subarray' => [
'sub_value_1',
'sub_key_2' => 'sub_value_2'
],
123,
new stdClass(),
function () {
}
];
echo pre($MyArray);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment