Ask about general coding issues or problems here.
Moderators: macek, egami, gesf
by chson » Thu Nov 14, 2002 5:06 pm
Does anybody know how I'd make the:
$test.$i
loop so it's read by the program as $test1 and then $test2?
The result of the program should be:
FAIL
PASS
- Code: Select all
<?
$test1 = 1;
$test2 = 2;
for ($i=1; $i<3; $i++) {
if ($test.$i == $test2)
echo "PASS<p>";
else
echo "FAIL<P>";
}
?>
-
chson
- New php-forum User

-
- Posts: 8
- Joined: Mon Oct 14, 2002 5:57 pm
by Dmitrit Plakhotnik » Fri Nov 15, 2002 1:25 am
Very simple:
- Code: Select all
<?
$test1 = 1;
$test2 = 2;
for ($i=1; $i<3; $i++) {
if (($test.$i) == $test2)
echo "PASS<p>";
else
echo "FAIL<P>";
}
?>
-
Dmitrit Plakhotnik
- New php-forum User

-
- Posts: 13
- Joined: Fri Nov 01, 2002 6:56 am
by chson » Fri Nov 15, 2002 9:13 pm
Thanks Dmitrit. I will give it a shot tommorrow.
-
chson
- New php-forum User

-
- Posts: 8
- Joined: Mon Oct 14, 2002 5:57 pm
by chson » Sat Nov 16, 2002 9:05 pm
What if there's also an array involved in the variable? This currently doesn't work:
if (($test.$i.[$i]) == $test2)
Neither does this:
if (($test.$i[$i]) == $test2)
-
chson
- New php-forum User

-
- Posts: 8
- Joined: Mon Oct 14, 2002 5:57 pm
by chson » Mon Nov 18, 2002 9:53 am
BUMP
-
chson
- New php-forum User

-
- Posts: 8
- Joined: Mon Oct 14, 2002 5:57 pm
Return to PHP coding => General
Who is online
Users browsing this forum: No registered users and 1 guest