Hi there
Im trying to print out something but im having errors with it
What I have is this
for ($x = 1; $x <= $fields; $x++)
{
echo "Required = {$_POST['required".$x."']}<br />";
}
It just prints out " Required = "
But when I print out
echo "Required = {$_POST['required1']}<br />";
It prints out what I want to print "Required = on"
It seems im making some basic error with the insertion of the $x variable but I cant figure it out
Can anyone help a brother?
Problem with Echoing a string
Moderator: General Moderators
-
Mark Baker
- Forum Regular
- Posts: 710
- Joined: Thu Oct 30, 2008 6:24 pm
Re: Problem with Echoing a string
Code: Select all
for ($x = 1; $x <= $fields; $x++) {
$req = 'required'.$x;
echo "Required = ".$_POST[$req]."<br />";
}
Re: Problem with Echoing a string
ChangeAnarking wrote:Hi there
Im trying to print out something but im having errors with it
What I have is this
for ($x = 1; $x <= $fields; $x++)
{
echo "Required = {$_POST['required".$x."']}<br />";
}
It just prints out " Required = "
But when I print out
echo "Required = {$_POST['required1']}<br />";
It prints out what I want to print "Required = on"
It seems im making some basic error with the insertion of the $x variable but I cant figure it out
Can anyone help a brother?
Code: Select all
$_POST['required".$x."']Code: Select all
$_POST['required'.$x]Re: Problem with Echoing a string
ah cheers
that'll do it
that'll do it