note 88227 added to function.str-repeat
| From: | KeesvanDieren at osu1 dot php dot net | Date: | Fri, 16 Jan 2009 09:26:55 +0000 |
| Subject: | note 88227 added to function.str-repeat | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-149307@lists.php.net to get a copy of this message | ||
Needed a function to repeat a string with a separator.
<?php
/**
* Repeats <tt>$string</tt> <tt>$multiplier</tt> times, separated with
<tt>$sep</tt>.
*
* str_repeat_sep('?', ',', 3) ==> "?,?,?"
* str_repeat_seap('..', '/', 3) ==> "../../.."
*
* @param string $string
* @param string $sep
* @param int $multiplier
* @return string
*/
function str_repeat_sep($string, $sep, $multiplier) {
$ret = "";
for($i=0;$i<$multiplier;$i++) {
if ($i) $ret.=$sep;
$ret.=$string;
}
return $ret;
}
?>
----
Server IP: 83.137.20.135
Probable Submitter: 145.7.91.126
----
Manual Page -- http://www.php.net/manual/en/function.str-repeat.php
Edit -- https://master.php.net/note/edit/88227
Del: integrated -- https://master.php.net/note/delete/88227/integrated
Del: useless -- https://master.php.net/note/delete/88227/useless
Del: bad code -- https://master.php.net/note/delete/88227/bad+code
Del: spam -- https://master.php.net/note/delete/88227/spam
Del: non-english -- https://master.php.net/note/delete/88227/non-english
Del: in docs -- https://master.php.net/note/delete/88227/in+docs
Del: other reasons-- https://master.php.net/note/delete/88227
Reject -- https://master.php.net/note/reject/88227
Search -- https://master.php.net/manage/user-notes.php