note 104080 deleted from function.serialize by thiago
| From: | thiago@php.net | Date: | Mon, 23 May 2011 14:15:43 +0000 |
| Subject: | note 104080 deleted from function.serialize by thiago | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-179969@lists.php.net to get a copy of this message | ||
Note Submitter: coolesting at gmail dot com
----
Hi, guys, i have a good function to render the array to a string as that original array, this is
very useful to be strong into php-script and database. if any problem, calling me with
coolesting@gmail.com
function c_arr2str($arr, $first = TRUE) {
static $string = '';
$string .= "array(";
if (count($arr)) {
foreach ($arr as $key => $val){
if (!is_array($val)) {
$string .= "'$key' => '$val',";
} else {
$string .= "'$key' => ";
c_arr2str($val, FALSE);
}
}
}
$string .= "),";
if ($first) $string = substr($string, 0 , -1) . ';';
return $string;
}