foreach under php prompts Warning: Solution of Invalid argument supplied for foreach of
- 2021-07-26 07:05:14
- OfStack
In this paper, the solution of foreach () error prompt Warning: Invalid argument supplied for foreach () under php is described by example. Share it for your reference. The specific implementation method is as follows:
1. Issues:
foreach () under php Error Prompt Warning: Invalid argument supplied for foreach ()
Error Prompt: Warning: Invalid argument supplied for foreach () in E: wampwwwmyshopcart. php on line 95
2. Solution:
Error Prompt Warning: Invalid argument supplied for foreach () in Chinese means that foreach needs to be an array and is given an invalid parameter.
Is in front of the loop to add a judgment, directly use is_array to determine whether the value is an array, the code is as follows:
if(is_array($items) && !emptyempty($items)){
foreach( )
}
Or cast the data type as follows:
foreach((array)$v as $k1 => $v1) {
$edu[$k1][$k] = my_h($v1);// v1 It is the data to be put into storage finally , Perform escape processing
}
I hope this article is helpful to everyone's php programming.