Forum Moderators: coopster

Message Too Old, No Replies

Maths. with a difference.

         

ahmedtheking

8:36 pm on Jan 19, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Is there a way to return a number repeated n number times?

For example, I have X, and I want X to be repeated, as a string rather than an int/float, N times, not in the sense: N x X or N^X. I want N to be NNNNNNNN where X = 8; ie N repeated 8 times (or X times).

I hope that makes sense.

ahmedtheking

8:41 pm on Jan 19, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



PS I just wrote this:

// repeat string function
function repeatStr ($str, $n) {
for ($x = 0; $x < $n; $++) {
$r .= $str;
}

return $r;

}

ahmedtheking

8:42 pm on Jan 19, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Oh no and I just found this: [uk.php.net...]