note 129461 added to function.implode
| From: | sphawk | Date: | Sat, 04 May 2024 06:40:42 +0000 |
| Subject: | note 129461 added to function.implode | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-221315@lists.php.net to get a copy of this message | ||
Another version of implode.
<?php
function ws_implode($prefix = null, $array = array(), $suffix = null) {
if (!is_null($prefix) && !is_string($prefix)) throw new Exception("Invalid
prefix");
if (!is_array($array)) throw new Exception("Invalid array");
if (!is_null($suffix) && !is_string($suffix)) throw new Exception("Invalid
suffix");
$text = "";
foreach ($array as $value) $text .= $prefix.$value.$suffix;
return $text;
}
$array = ["a", "b", "c"];
echo ws_implode("letter ", $array, "!<br>");
?>
Output:
letter a!<br>
letter b!<br>
letter c!<br>
----
Server IP: 45.112.84.4
Probable Submitter: 80.90.13.131 (proxied: 195.32.34.162)
----
Manual Page -- https://php.net/manual/en/function.implode.php
Edit -- https://main.php.net/note/edit/129461
Del: integrated -- https://main.php.net/note/delete/129461/integrated
Del: useless -- https://main.php.net/note/delete/129461/useless
Del: bad code -- https://main.php.net/note/delete/129461/bad+code
Del: spam -- https://main.php.net/note/delete/129461/spam
Del: non-english -- https://main.php.net/note/delete/129461/non-english
Del: in docs -- https://main.php.net/note/delete/129461/in+docs
Del: other reasons-- https://main.php.net/note/delete/129461
Reject -- https://main.php.net/note/reject/129461
Search -- https://main.php.net/manage/user-notes.php