Voting

: min(eight, zero)?
(Example: nine)

The Note You're Voting On

linus at flowingcreativity dot net
19 years ago
<roman at DIESPAM dot feather dot org dot ru>, your function has inefficiencies and problems. I probably speak for everyone when I ask you to test code before you add to the manual.

Since the issue of whitespace only comes up when exporting arrays, you can use the original var_export() for all other variable types. This function does the job, and, from the outside, works the same as var_export().

<?php

function var_export_min($var, $return = false) {
if (
is_array($var)) {
$toImplode = array();
foreach (
$var as $key => $value) {
$toImplode[] = var_export($key, true).'=>'.var_export_min($value, true);
}
$code = 'array('.implode(',', $toImplode).')';
if (
$return) return $code;
else echo
$code;
} else {
return
var_export($var, $return);
}
}

?>

<< Back to user notes page

To Top