PHP under foreach hint warning:invalid argument supplied for foreach () workaround, foreachsupplied_php tutorial

Source: Internet
Author: User

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 ...

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.