Hey All -
Im passing an array with 7 elements with 2 sub elements in to a function inside a class. I have $array[0][0] - $array[6][1].
When I use foreach() inside the function (to loop the array) - I get this error:
Warning: Invalid argument supplied for foreach()
I echoed out the var in the function, and it is an array!!
here is the culprit:
function change_hours($hsa) {
$c=0;
foreach($hsa as $hs) { // error on this line!!
// get hours and codes
if($c==0) {
$this->sat = $this->mh->fix_format($hs[0]);
$sat1 = $this->mh->fix_format($hs[1]);
}
if($c==2) {
$this->mon = $this->mh->fix_format($hs[0]);
$mon1 = $this->mh->fix_format($hs[1]);
}
if($c==3) {
$this->tue = $this->mh->fix_format($hs[0]);
$tue1 = $this->mh->fix_format($hs[1]);
}
if($c==4) {
$this->wed = $this->mh->fix_format($hs[0]);
$wed1 = $this->mh->fix_format($hs[1]);
}
if($c==5) {
$this->thu = $this->mh->fix_format($hs[0]);
$thu1 = $this->mh->fix_format($hs[1]);
}
if($c==6) {
$this->fri = $this->mh->fix_format($hs[0]);
$fri1 = $this->mh->fix_format($hs[1]);
}
$c++;
}
// rest of the function here
}
any ideas.
Cheers,
Stuart