syntax?<

hrm does anyone know if this will work?

var $x2 = array();

for ($x = 1; $x <= 10; $x++)
{
$eStr = "\$db->f('ipv4_" . ($x < 10) ? "0" . $x : x . "');";
$x2[$x] = eval($eStr);
}

im not sure about the ? : part..

-flYou have the syntax correct for the ? : part, but you have a couple other problems.

First, you have to take out the var in the first line.

Second, in the ? : part, the second x is missing it's dollar sign.

Lastly, you need to put the whole question mark part in parenthases so that it knows where the statement begins and ends.

Here's what it looks like with all the fixes:

$x2 = array();

for ($x = 1; $x <= 10; $x++)
{
$eStr = "\$db->f('ipv4_" . (($x < 10) ? "0" . $x : $x) . "');";
$x2[$x] = eval($eStr);
}
 
Back
Top