function views_var_export

Export a field.

2 calls to views_var_export()
views_handler_filter_in_operator::validate in handlers/views_handler_filter_in_operator.inc
Validates the handler against the complete View.
views_object::export_option in includes/base.inc

File

./views.module, line 2556

Code

function views_var_export($var, $prefix = '', $init = TRUE) {
    if (is_array($var)) {
        if (empty($var)) {
            $output = 'array()';
        }
        else {
            $output = "array(\n";
            foreach ($var as $key => $value) {
                $output .= "  " . views_var_export($key, '', FALSE) . " => " . views_var_export($value, '  ', FALSE) . ",\n";
            }
            $output .= ')';
        }
    }
    elseif (is_bool($var)) {
        $output = $var ? 'TRUE' : 'FALSE';
    }
    elseif (is_string($var) && strpos($var, "\n") !== FALSE) {
        // Replace line breaks in strings with a token for replacement
        // at the very end. This protects multi-line strings from
        // unintentional indentation.
        $var = str_replace("\n", "***BREAK***", $var);
        $output = var_export($var, TRUE);
    }
    else {
        $output = var_export($var, TRUE);
    }
    if ($prefix) {
        $output = str_replace("\n", "\n{$prefix}", $output);
    }
    if ($init) {
        $output = str_replace("***BREAK***", "\n", $output);
    }
    return $output;
}