note 58320 deleted from function.implode by hholzgra
| From: | hholzgra@php.net | Date: | Thu, 02 Aug 2012 13:17:05 +0000 |
| Subject: | note 58320 deleted from function.implode by hholzgra | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-189730@lists.php.net to get a copy of this message | ||
Note Submitter: adrian at foeder dot de
----
...and a mysql-update-statement-compatible implementation of implode_with_keys:
<?php
function implode_with_keys($glue, $array, $valwrap='')
{
foreach($array AS $key => $value) {
$ret[] = $key."=".$valwrap.$value.$valwrap;
}
return implode($glue, $ret);
}
?>
so implode_with_keys(", ", $array, "'") will output:
key1='value1', key2='value2'
and so on. Useful for UPDATE table SET key1='value1', key2='value2'