| |
|
Repeating String str_repeat function |
Using str_repeat string function we can repeat a string by a number ( known as multiplier ). Say we want to repeat a string $ for ten times, here is the syntax for the function str_repeat.
str_repeat (input string, int multiplier );
Here is one example
echo str_repeat(“$”,10);
The above command will print $ ten times.
Now let us move to another example. How about printing such a pattern ?
* ** *** **** ***** ****** ******* ******** ********* **********
Here is the code for this
for($i=1;$i<=10;$i++){
echo str_repeat("*",$i);
echo "<br>";
}
| |
| Subscribe |
|
Submit your email address and receive
article and product notifications. Your email is safe with us.
|
|
|
|
|
|