displaying a sentence the amount of times assigned by the user

Hi What I need to do is the user types in a sentence and a number and the sentence will be displayed the amount of the number the user asked for. I do have the sentence displaying but I can't figure out how to make is display x amount of times. Please advise. Thank you in advance. :o
<h2 style="text-align: center">Q4 Form</h2>
<form name="Q4" action=
<p>Sentences: <input type="text" name="wSentence" /></p>
<p>Number: <input type="text" name="anumber" /></p>
 <p><input type="reset" value="Clear Form" />&nbsp;
&nbsp;<input type="submit" name="Submit" value=
"Send Form"/></p>


	$sentences = $_POST['wSentence'];
	$number = $_POST['anumber'];
	echo "Is this the sentence you typed,



Hi there,

I believe the function you are after is str_repeat(). Example below:
[php]$string = “Hello”;
$repeat = 4;
echo str_repeat($string,$repeat);

That outputs “HelloHelloHelloHello”.


Hi again I'm not sure if that will work because the user will assign the value in the form then click submit and the sentence that he type will repeat the amount of types he assigned.

Thank you

Yes, that is why I stated that it was just an example, for you to adjust as necessary. But I have done so for you:

[php]$string = $_POST[‘wSentence’];
$repeat = $_POST[‘anumber’];
echo str_repeat($string,$repeat);

Sponsor our Newsletter | Privacy Policy | Terms of Service