Basic Question

Ask about general coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply
chson
New php-forum User
New php-forum User
Posts: 8
Joined: Mon Oct 14, 2002 5:57 pm

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>";
}

?>

Dmitrit Plakhotnik
New php-forum User
New php-forum User
Posts: 13
Joined: Fri Nov 01, 2002 6:56 am

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>";
}

?>
--
Sincerely,
Dmitriy S. Plakhotnik
AlarIT programmer
http://www.AlarIT.com

chson
New php-forum User
New php-forum User
Posts: 8
Joined: Mon Oct 14, 2002 5:57 pm

Fri Nov 15, 2002 9:13 pm

Thanks Dmitrit. I will give it a shot tommorrow.

chson
New php-forum User
New php-forum User
Posts: 8
Joined: Mon Oct 14, 2002 5:57 pm

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
New php-forum User
Posts: 8
Joined: Mon Oct 14, 2002 5:57 pm

Mon Nov 18, 2002 9:53 am

BUMP

Post Reply
  • Information
  • Who is online

    Users browsing this forum: hyper and 5 guests