Vincent Dagpin
Vincent Dagpin

Reputation: 3611

Repeat a character N times

Is there any other way to print 40 dots in php?

I have this in my mind but I think this is wrong.. maybe there was a way like this.

<?php print(".",40);  ?>

Is it possible to do in that way? without the use of looping?

Upvotes: 0

Views: 239

Answers (2)

atif
atif

Reputation: 87

If you don't want to use any loop then the PHP function str_repeat() will work correctly here. Another approach is to do this by the use of arrays.

Upvotes: 0

Mike Johnson
Mike Johnson

Reputation: 351

Yes ! use the str_repeat function:

echo str_repeat('.', 40);

Upvotes: 8

Related Questions