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=
	"process_Q4.php"
	 method="post">
<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>
</form>

<html>
<?php

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

?>

<html>

Hi there,

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

That outputs “HelloHelloHelloHello”.

http://uk.php.net/str_repeat

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);
[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service