PHP under foreach hint warning:invalid argument supplied for foreach () workaround, foreachsupplied
This example describes the workaround for the foreach () error hint warning:invalid argument supplied for foreach () under PHP. Share to everyone for your reference. The implementation method is as follows:
First, the question:
PHP under foreach () error hint warning:invalid argument supplied for foreach ()
Error tip: warning:invalid argument supplied for foreach () in e:wampwwwmyshopcart.php on line 95
Second, the solution:
Error Warning:invalid argument supplied for foreach () in Chinese means that foreach needs to be an array and give it an invalid argument.
is to add a judgment in front of the loop, directly using Is_array to determine the value is not an array, the code is as follows:
Copy the code as follows: if (Is_array ($items) &&!emptyempty ($items)) {
foreach ()
}
Or cast the data type, the code is as follows:
Copy the code as follows: foreach ((array) $v as $k 1 = $v 1) {
$edu [$k 1][$k] = My_h ($v 1);//V1 is the final data to be put into storage for escape processing
}
I hope this article is helpful to everyone's PHP programming.
http://www.bkjia.com/PHPjc/909335.html www.bkjia.com true http://www.bkjia.com/PHPjc/909335.html techarticle php under foreach hint warning:invalid argument supplied for foreach solution, foreachsupplied This example describes the PHP under the foreach () Error message warning:invalid argument suppli ...