How to traverse an associative array
Posted: Sat Jul 18, 2009 2:47 pm
When i run the given below PHP code i get the follwing error:
Warning: Invalid argument supplied for foreach() in C:\xampp\htdocs\LOGISTICS&MOB\trial\untitled.php on line 31
THe Code is given below
pls help me.. I getting stucked.. SOS
Thanking in advance.
Monindra Masia
Warning: Invalid argument supplied for foreach() in C:\xampp\htdocs\LOGISTICS&MOB\trial\untitled.php on line 31
THe Code is given below
Code: Select all
while ($rows[] = mysql_fetch_assoc($ManpowerResult)) { }
$i=0;
print_r($rows);
echo"-----------------------";
foreach($rows as $arrays) { [i][u][b] //this is the line number 31 [/b][/u][/i] $i=0;
foreach ($arrays as $field => $value) {
if($i==0)
{
$obj[$field][] = $value;
}
else
{
$obj[$field][] = $value*$contact_rate[$field];
}
$i++;
}
//echo "<br />";
}
}
Thanking in advance.
Monindra Masia