I am getting the following errors:
Warning: Argument to keys() should be an array in main.inc on line 152
Warning: Non array argument supplied for foreach() in main.inc on line 152
I've developed the site on my linux box at home using PHP 4.0.3pl1. It works great, but when I upload it to my hosting service I get the above messages. I've tried all the different ways to go through an associative array. I've tried doing an implode(array_keys($arr), ',') then split on ','. It keeps coming back to the fact that it doesn't recognize the array I declare right before it is an array.
Now the hosting service runs a BSD Bosx and uses PHP 4.0b2. I'm wondering if this was a problem with the second beta release or if it is something screwy between platforms. Look below for the actual code.
Thanks,
Tim
The code looks like:
<?php
$image_array = array (
"about_on" => "images/menu_about2.gif",
"about_off" => "images/menu_about.gif",
"scribble_on" => "images/menu_scribble2.gif",
"scribble_off" => "images/menu_scribble.gif",
"code_on" => "images/menu_code2.gif",
"code_off" => "images/menu_code.gif",
"windows_on" => "images/menu_windows2.gif",
"windows_off" => "images/menu_windows.gif",
"job_on" => "images/menu_job2.gif",
"job_off" => "images/menu_job.gif",
"etc_on" => "images/menu_etc2.gif",
"etc_off" => "images/menu_etc.gif",
"contact_on" => "images/menu_contact.gif",
"contact_off" => "images/menu_contact.gif"
);
foreach ( array_keys($image_array) as $kind){
if ($type == $kind){
$img_switch = $kind . "_on";
}
else{
$img_switch = $kind . "_off";
}
$image_path =
$image_array[$kind][$img_switch];
print "
<tr>
<td><a href=\"index.php?menu=$kind\" onMouseOut=\"MM_swapImgRestore()\" onMouseOver=\"MM_swapImage('document.$kind','document.$kind','images/menu_" . $kind . "2.gif','#1');\"><img src=\"$image_path\" alt=\"$kind\" name=\"$kind\" border=0></a></td>
</tr>
";
}
?>