note 25278 added to function.str-repeat

From: Date: Tue, 17 Sep 2002 21:15:54 +0000
Subject: note 25278 added to function.str-repeat
Groups: php.notes 
Request: Send a blank email to php-notes+get-36859@lists.php.net to get a copy of this message
I little typo. doesn't effect the code but can waste string space... Please note the removal of "strlen($input) *" from the previous to the current post: (oops, I don't know what I was on with the previous post!!!).. Updated (corrected) function: <?php // use this function: function str_repeat2($input, $length) { // returns the output exactly $length using $input to fill that length $answer=""; if ($length>=1 && strlen($input)>=1) { $answer = substr(str_repeat($input, ceil($length/strlen($input)) ), 0, $length); } return $answer; } //demo the function's use: $t="-=-"; print str_repeat2($t,0)."\n"; print str_repeat2($t,1)."\n"; print str_repeat2($t,2)."\n"; print str_repeat2($t,3)."\n"; print str_repeat2($t,4)."\n"; print str_repeat2($t,5)."\n"; print str_repeat2($t,6)."\n"; ?> -- http://www.php.net/manual/en/function.str-repeat.php http://master.php.net/manage/user-notes.php?action=edit+25278 http://master.php.net/manage/user-notes.php?action=delete+25278 http://master.php.net/manage/user-notes.php?action=reject+25278

« previous php.notes (#36859) next »