function entity_var_export in Entity API 7
Export a variable. Copied from ctools.
This is a replacement for var_export(), allowing us to more nicely format exports. It will recurse down into arrays and will try to properly export bools when it can.
File
- ./
entity.module, line 773
Code
function entity_var_export($var, $prefix = '') {
if (is_array($var)) {
if (empty($var)) {
$output = 'array()';
}
else {
$output = "array(\n";
foreach ($var as $key => $value) {
$output .= " '{$key}' => " . entity_var_export($value, ' ') . ",\n";
}
$output .= ')';
}
}
elseif (is_bool($var)) {
$output = $var ? 'TRUE' : 'FALSE';
}
else {
$output = var_export($var, TRUE);
}
if ($prefix) {
$output = str_replace("\n", "\n{$prefix}", $output);
}
return $output;
}