00001 <?php 00002 // +----------------------------------------------------------------------+ 00003 // | PHP Version 4 | 00004 // +----------------------------------------------------------------------+ 00005 // | Copyright (c) 1997-2004 The PHP Group | 00006 // +----------------------------------------------------------------------+ 00007 // | This source file is subject to version 3.0 of the PHP license, | 00008 // | that is bundled with this package in the file LICENSE, and is | 00009 // | available at through the world-wide-web at | 00010 // | http://www.php.net/license/3_0.txt. | 00011 // | If you did not receive a copy of the PHP license and are unable to | 00012 // | obtain it through the world-wide-web, please send a note to | 00013 // | license@php.net so we can mail you a copy immediately. | 00014 // +----------------------------------------------------------------------+ 00015 // | Authors: Aidan Lister <aidan@php.net> | 00016 // +----------------------------------------------------------------------+ 00017 // 00018 // $Id: var_export.php 2 2009-03-16 20:22:51Z ggiunta $ 00019 00020 00032 if (!function_exists('var_export')) { 00033 function var_export($array, $return = false, $lvl=0) 00034 { 00035 // Common output variables 00036 $indent = ' '; 00037 $doublearrow = ' => '; 00038 $lineend = ",\n"; 00039 $stringdelim = '\''; 00040 00041 // Check the export isn't a simple string / int 00042 if (is_string($array)) { 00043 $out = $stringdelim . str_replace('\'', '\\\'', str_replace('\\', '\\\\', $array)) . $stringdelim; 00044 } elseif (is_int($array) || is_float($array)) { 00045 $out = (string)$array; 00046 } elseif (is_bool($array)) { 00047 $out = $array ? 'true' : 'false'; 00048 } elseif (is_null($array)) { 00049 $out = 'NULL'; 00050 } elseif (is_resource($array)) { 00051 $out = 'resource'; 00052 } else { 00053 // Begin the array export 00054 // Start the string 00055 $out = "array (\n"; 00056 00057 // Loop through each value in array 00058 foreach ($array as $key => $value) { 00059 // If the key is a string, delimit it 00060 if (is_string($key)) { 00061 $key = str_replace('\'', '\\\'', str_replace('\\', '\\\\', $key)); 00062 $key = $stringdelim . $key . $stringdelim; 00063 } 00064 00065 $val = var_export($value, true, $lvl+1); 00066 // Delimit value 00067 /*if (is_array($value)) { 00068 // We have an array, so do some recursion 00069 // Do some basic recursion while increasing the indent 00070 $recur_array = explode($newline, var_export($value, true)); 00071 $temp_array = array(); 00072 foreach ($recur_array as $recur_line) { 00073 $temp_array[] = $indent . $recur_line; 00074 } 00075 $recur_array = implode($newline, $temp_array); 00076 $value = $newline . $recur_array; 00077 } elseif (is_null($value)) { 00078 $value = 'NULL'; 00079 } else { 00080 $value = str_replace($find, $replace, $value); 00081 $value = $stringdelim . $value . $stringdelim; 00082 }*/ 00083 00084 // Piece together the line 00085 for ($i = 0; $i < $lvl; $i++) 00086 $out .= $indent; 00087 $out .= $key . $doublearrow . $val . $lineend; 00088 } 00089 00090 // End our string 00091 for ($i = 0; $i < $lvl; $i++) 00092 $out .= $indent; 00093 $out .= ")"; 00094 } 00095 00096 // Decide method of output 00097 if ($return === true) { 00098 return $out; 00099 } else { 00100 echo $out; 00101 return; 00102 } 00103 } 00104 } 00105 ?>
Copyright © 2003 - 2009 MyOOS [Shopsystem]. All rights reserved. MyOOS [Shopsystem] is Free Software released under the GNU/GPL License. Webmaster: info@r23.de (Impressum) |
|