note 60318 deleted from function.implode by hholzgra
| From: | hholzgra@php.net | Date: | Thu, 02 Aug 2012 13:17:13 +0000 |
| Subject: | note 60318 deleted from function.implode by hholzgra | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-189731@lists.php.net to get a copy of this message | ||
Note Submitter: dabduster at gmail dot com
----
an implementation of adrian at foeder dot de implode_with_keys function for input and update sql
statement.
function implode_param($glue, $array, $valwrap='', $mode = 0)
{
/*
if mode = 0 output is key and values
if mode = 1 output only keys
if mode = 2 output only values
*/
switch ($mode){
case 1:
foreach($array AS $key => $value) {
$ret[] = $valwrap.$key.$valwrap;
}
break;
case 2:
foreach($array AS $key => $value) {
$ret[] = $valwrap.$value.$valwrap;
}
break;
default:
case 0:
foreach($array AS $key => $value) {
$ret[] = $key."=".$valwrap.$value.$valwrap;
}
break;
}
return implode($glue, $ret);
}