note 110067 added to function.var-export
| From: | kexianbin at diyism dot com | Date: | Sun, 16 Sep 2012 02:33:58 +0000 |
| Subject: | note 110067 added to function.var-export | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-190802@lists.php.net to get a copy of this message | ||
to use my_var_export(), it is as beautiful as var_export() and as could deal with recursive
reference as print_r():
<?php
function my_var_export($var, $is_str=false)
{$rtn=preg_replace(array('/Array\s+\(/', '/\[(\d+)\] => (.*)\n/',
'/\[([^\d].*)\] => (.*)\n/'), array('array (', '\1 =>
\'\2\''."\n", '\'\1\' =>
\'\2\''."\n"), substr(print_r($var, true), 0, -1));
$rtn=strtr($rtn, array("=> 'array ('"=>'=> array
('));
$rtn=strtr($rtn, array(")\n\n"=>")\n"));
$rtn=strtr($rtn, array("'\n"=>"',\n",
")\n"=>"),\n"));
$rtn=preg_replace(array('/\n +/e'), array('strtr(\'\0\',
array(\' \'=>\' \'))'), $rtn);
$rtn=strtr($rtn, array(" Object',"=>" Object'<-"));
if ($is_str)
{return $rtn;
}
else
{echo $rtn;
}
}
?>
----
Server IP: 69.147.83.199
Probable Submitter: 58.246.119.46
----
Manual Page -- http://www.php.net/manual/en/function.var-export.php
Edit -- https://master.php.net/note/edit/110067
Del: integrated -- https://master.php.net/note/delete/110067/integrated
Del: useless -- https://master.php.net/note/delete/110067/useless
Del: bad code -- https://master.php.net/note/delete/110067/bad+code
Del: spam -- https://master.php.net/note/delete/110067/spam
Del: non-english -- https://master.php.net/note/delete/110067/non-english
Del: in docs -- https://master.php.net/note/delete/110067/in+docs
Del: other reasons-- https://master.php.net/note/delete/110067
Reject -- https://master.php.net/note/reject/110067
Search -- https://master.php.net/manage/user-notes.php