Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/262.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
foreach循环不能正确使用json编码Php_Php_Codeigniter_Loops_Foreach - Fatal编程技术网

foreach循环不能正确使用json编码Php

foreach循环不能正确使用json编码Php,php,codeigniter,loops,foreach,Php,Codeigniter,Loops,Foreach,我有多个数组(数组中的对象),但我从未运行过foreach循环,它可以工作 只有一次,有什么问题?我错在哪里 Array ( [0] => stdClass Object ( [_id] => 5cc6896028497b75f44cbf31 } [1] => stdClass Object ( [_id] => 5cc6896028497b75f44cbf32

我有多个数组(数组中的对象),但我从未运行过foreach循环,它可以工作 只有一次,有什么问题?我错在哪里

Array
(
    [0] => stdClass Object
        (
            [_id] => 5cc6896028497b75f44cbf31
        }
    [1] => stdClass Object
        (
            [_id] => 5cc6896028497b75f44cbf32
        }
    ... 
}       
这是我的代码,但循环只在一段时间内工作,但我有很多记录(超过100条)


您可以重写foreach循环:

<?php

$final = json_decode($response,true);

foreach($final as $key => $re)
   {
     echo $re['_id']. "<br>";
   }

数组响应中的数据在哪里?
$record
包含什么?为什么不迭代一下
$final
?你能在这里分享你的
$response
吗?你基本上是说数组表示法有效-但对象表示法无效-逻辑从何而来?
<?php

$final = json_decode($response,true);

foreach($final as $key => $re)
   {
     echo $re['_id']. "<br>";
   }