note 44836 added to function.implode
| From: | ChrisRoss at osu1 dot php dot net | Date: | Tue, 17 Aug 2004 18:18:02 +0000 |
| Subject: | note 44836 added to function.implode | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-79958@lists.php.net to get a copy of this message | ||
I took static's implode_with_keys, and converted into something I considered a little more
programatically useful. I would argue that this sort of functionality should maybe be added to PHP.
<?php
/* This isn't really DB function, but it's general... This will */
/* act like the PHP implode() function, but for assoc. arrays... */
function implode_assoc($inner_glue, $outer_glue, $array) {
$output = array();
foreach( $array as $key => $item )
$output[] = $key . $inner_glue . $item;
return implode($outer_glue, $output);
}
?>
It's the same as static's, really, but allows you to join the keys to the values with
any arbitrary string, rather than hard-coding a '='.
----
Manual Page -- http://www.php.net/manual/en/function.implode.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+44836
Delete -- http://master.php.net/manage/user-notes.php?action=delete+44836&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+44836&report=yes
Search -- http://master.php.net/manage/user-notes.php