note 75710 deleted from function.implode by felipe
| From: | felipe@php.net | Date: | Mon, 24 Dec 2007 02:13:44 +0000 |
| Subject: | note 75710 deleted from function.implode by felipe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-133939@lists.php.net to get a copy of this message | ||
Note Submitter: Brian
----
A simple extension to implode, which includes a second gluing of keys. Particularly handy when
managing $_GET and $_POST.
<?
function implode_assoc($glue1, $glue2, $array){
foreach($array as $key => $val)
$array2[] = $key.$glue1.$val;
return implode($glue2, $array2);
}
//usage:
$array["key"]="val";
$array["key2"]="val2";
implode_assoc("=", "&", $array); //returns "key=val&key2=val2"
?>