<?php
$i == array(1, 2);
$j == array(a, b);
$m == count($j);
$n == count($i);
for ( $i = 0; $i < $m; i++ )
{
for ( $j = 0; j < $n; j++)
{ echo $i."x"$j; }
}
?>
The error is referencing line 6: for ( $i = 0; $i < $m; i++ )
for ( $i = 0; $i < $m; $i++ )Note the dollar sign I added before the
i++Same goes for your other
forstatement:for ( $j = 0; $j < $n; $j++ )Wierd error indeed, but it
iis not a variable (although PHP might flag aE_NOTICEand convert it to'i'. You want to reference your variable, so you must add a$before.Most likely what you want is:
The things I changed:
==is used for comparison,=is used for assignment'a'and'b', but you could have also wanted$aand$bif you declared those variables somewhere else$ito an array, but then in your for loop you overwrite it with$i = 0. You most likely want two variables$s, like I mentioned above$mwas being used for the number of variables in$jArray, but you used it to iterate over$iArraySo just a few pointers, brush up on you PHP and try to make sure your code works with every little change. Make 1 modification, then run it. It is very easy to get lost in syntax for PHP since it is such a dynamic scripting language