This question already has an answer here:
- Invalid argument supplied for foreach() 19 answers
I'm trying to make a shoping cart in which this product() is used for displaying what is in cart but in foreach statement it shows Warning: Invalid argument supplied for foreach()
function product()
{
foreach(@$_SESSION as $name=>$value)
{
if($value>0)
{
if(substr($name,0,5) == 'cart_'){
$id= substr($name,5,(strlen($name-5)));
echo $id;
}
}
}
}
</div>