note 82247 added to function.implode
| From: | wesleys at opperschaap dot net | Date: | Wed, 02 Apr 2008 14:11:16 +0000 |
| Subject: | note 82247 added to function.implode | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-137861@lists.php.net to get a copy of this message | ||
The previous p_join function had some bugs, and code which got repeated. Changed it a bit, so here
it is:
function p_join() {
$args = func_get_args();
if (count($args) > 1) {
$result = "";
$sep = array_shift($args);
foreach ($args as $val) {
if (is_array($val)) {
if (is_assoc_array($val)) {
$result .= _p_join_assoc($sep, $val);
} else {
$result .= $sep . _p_join_array($sep, $val);
}
continue;
}
$result .= $sep . $val;
}
# $result will always start with a $sep, so remove it..
return substr_replace($result, "" ,0, strlen($sep));
}
trigger_error(sprintf("%s requires at least 2 parameters",
__FUNCTION__), E_USER_WARNING);
return null;
}
----
Server IP: 195.184.64.198
Probable Submitter: 194.134.32.189
----
Manual Page -- http://www.php.net/manual/en/function.implode.php
Edit -- https://master.php.net/note/edit/82247
Del: integrated -- https://master.php.net/note/delete/82247/integrated
Del: useless -- https://master.php.net/note/delete/82247/useless
Del: bad code -- https://master.php.net/note/delete/82247/bad+code
Del: spam -- https://master.php.net/note/delete/82247/spam
Del: non-english -- https://master.php.net/note/delete/82247/non-english
Del: in docs -- https://master.php.net/note/delete/82247/in+docs
Del: other reasons-- https://master.php.net/note/delete/82247
Reject -- https://master.php.net/note/reject/82247
Search -- https://master.php.net/manage/user-notes.php