杰奇小说采集规则手机版:Warning: Invalid argument supplied for foreach() in D:\www\index.php on line 9

PHP:Invalid argument supplied for foreach 解决办法 - msnshow的个人空间 - 51Testing软件测试网 51Testing软件测试网-中国软件测试人的精神家园
有正在从事web测试和APP测试工作或想从事此行业的测友们,欢迎与我联系,相互交流!测试交流微信公众号:gh_03e570cb5168
长期招聘不同级别测试工程师(WEB\APP\性能)有意者请与本人联系!
PHP:Invalid argument supplied for foreach 解决办法
& 14:03:49
/ 个人分类:
Warning:&Invalid&argument&supplied&for&foreach()&问题Warning:&Invalid&argument&supplied&for&foreach()&in&完善解决方案将报错的语句做如下修改(例):把QUOTE:foreach($extcredits&as&$id&=&&$credit)&{&&&&&&&&&if($credit['ratio'])&&&&&&&&&&{&&&&&&&&&&&&&&&&&$exchcredits[$id]&=&$&&&&&&&&&}}改为QUOTE:if(is_array($extcredits))&&&&//add{&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&foreach($extcredits&as&$id&=&&$credit)&&&&&&&&&&{&&&&&&&&&&&&&&&&&&if($credit['ratio'])&&&&&&&&&&&&&&&&&&&{&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&$exchcredits[$id]&=&$&&&&&&&&&&&&&&&&&&}&&&&&&&&&&&&&&&&&}}&&&//add或QUOTE:foreach((array)$extcredits&as&$id&=&&$credit)&{&&&&&&&&&if($credit['ratio'])&&&&&&&&&&{&&&&&&&&&&&&&&&&&$exchcredits[$id]&=&$&&&&&&&&&}}造成这个错误的原因多数是因为论坛升级、编码转换造成的!如果对熟悉的人,可以直接找到出错的地方,分析出错信息是对哪个表操作时造成的(一般都是论坛的基本数据表),然后,找到相应表的原版数据导进去,问题可解决。如果对PHP不熟悉的人,可以按出错信息提示的位置,用2楼的修改方法进行修改,问题可解决。&PHP Warning: Invalid argument supplied for foreach() - Stack Overflow
Join Stack Overflow to learn, share knowledge, and build your career.
or sign in with
Why am I getting this PHP Warning?
Invalid argument supplied for foreach()
Here is my code:
// look for text file for this keyword
if (empty($site["textdirectory"])) {
$site["textdirectory"] = "text";
if (file_exists(ROOT_DIR.$site["textdirectory"].'/'.urlencode($q).'.txt')) {
$keywordtext =
file_get_contents(ROOT_DIR.$site["textdirectory"].'/'.urlencode($q).'.txt');
$keywordtext =
$keywordsXML = getEbayKeywords($q);
foreach($keywordsXML-&PopularSearchResult as $item) {
$topicsString = $item-&AlternativeS
$relatedString = $item-&RelatedS
if (!empty($topicsString)) {
split(";",$topicsString);
if (!empty($relatedString)) {
$related = split(";",$relatedString);
$node = array();
$node['keywords'] = $q;
$xml = ebay_rss($node);
$ebayItems = array();
$totalItems = count($xml-&channel-&item);
$totalPages = $totalItems / $pageS
($xml-&channel-&item as $item) {
$ebayRss =
$item-&children('http://www.ebay.com/marketplace/search/v1/services');
if ($i&=($pageSize*($page-1)) && $i&($pageSize*$page)) {
$newItem = array();
$newItem['title'] = $item-&
$newItem['link'] = buyLink($item-&link, $q);
$newItem['image'] = ebay_stripImage($item-&description);
$newItem['currentbid'] = ebay_convertPrice($item-&description);
$newItem['bidcount'] = $ebayRss-&BidC
$newItem['endtime'] = ebay_convertTime($ebayRss-&ListingEndTime);
$newItem['type'] = $ebayRss-&ListingT
if (!empty($ebayRss-&BuyItNowPrice)) {
$newItem['bin'] = ebay_convertPrice($item-&description);
array_push($ebayItems, $newItem);
$pageNumbers = array();
for ($i=1; $i&=$totalP $i++) {
array_push($pageNumbers, $i);
// get user guides
$guidesXML = getEbayGuides($q);
$guides = array();
foreach ($guidesXML-&guide as $guideXML) {
$guide = array();
$guide['url'] = makeguideLink($guideXML-&url, $q);
$guide['title'] = $guideXML-&
$guide['desc'] = $guideXML-&
array_push($guides,$guide);
What causes this warning?
9,88142143
You should check that what you are passing to foreach is an array by using the
If you are not sure it's going to be an array you can always check using the following PHP example code:
if (is_array($variable)) {
foreach ($variable as $item) {
//do something
17.6k74973
This means that you are doing a foreach on something that is not an array.
Check out all your foreach statements, and look if the thing before the as, to make sure it is actually an array.
Use var_dump to dump it.
Then fix the one where it isn't an array.
How to reproduce this error:
$skipper = "abcd";
foreach ($skipper as $item){
//the warning happens on this line.
print "ok";
Make sure $skipper is an array.
73.5k33294245
53.3k1391136
Because, on whatever line the error is occurring at (you didn't tell us which that is), you're passing something to foreach that is not an array.
Look at what you're passing into foreach, determine what it is (with ), find out why it's not an array... and fix it.
Basic, basic debugging.
262k46418707
if(is_array($value) || is_object($value)){
foreach($value as $item){
//somecode
6,408156097
Your Answer
Sign up or
Sign up using Google
Sign up using Facebook
Post as a guest
Post as a guest
By posting your answer, you agree to the
Not the answer you're looking for?
Browse other questions tagged
Stack Overflow works best with JavaScript enabled杰奇小说手机版:Warning: Invalid argument supplied for foreach() in D:\www\index.php on line 9_百度知道
杰奇小说手机版:Warning: Invalid argument supplied for foreach() in D:\www\index.php on line 9
9 foreach($qt as $v){
$arr[$k1][articleid] = $v-&
$arr[$k1][shortid] = intval($v-&articleid / 1000);
$arr[$k1][articlename] = $v-&
$arr[$k1][intro] = $v-&
$arr[$k1][author] = $v-&
...
没有财富值了,回答后测试没问题给红,请留VX
我有更好的答案
php的warning错误可以忽略的修改下php.ini
找到display_error 改为 Off
为您推荐:
换一换
回答问题,赢新手礼包
个人、企业类
违法有害信息,请在下方选择后提交
色情、暴力
我们会通过消息、邮箱等方式尽快将举报结果通知您。}

我要回帖

更多关于 argument for 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信