dongqian3750 2018-11-12 19:26
浏览 63

我如何使用非常大的数组/ JS对象? [重复]

This question already has an answer here:

I have a JS object of very large size that I can get through the curl, which I need to break apart for further writing to MYSQL. But when I try to walk through it with the forech cycle, I encounter a problem of not enough memory_size. Are there any options to handle the array with less load on the server without add memory size in php? Here is my code but it does not work

Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 20480 bytes)

<?php
#ini_set('memory_limit', '-1');
    if( $curl = curl_init() ) {
    curl_setopt($curl, CURLOPT_AUTOREFERER, TRUE); 
    curl_setopt($curl, CURLOPT_HEADER, 0); 
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); 
    curl_setopt($curl, CURLOPT_URL, $url); 
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, TRUE);  
    curl_setopt($curl,CURLOPT_URL,'http://img.combats.com/auction/dump.js');
    curl_setopt($curl,CURLOPT_RETURNTRANSFER,true);
    $out_shortinfo = curl_exec($curl);
    $json = json_decode(str_replace('var auction_dump=', '', $out_shortinfo), true);
    foreach ($json as $key=>$value) {
    if($key > 0)
        {
            echo $value['name'].' ';
            echo $value['txt'].' ';
            echo $value['_auc']['id'].'<br>';
        }
    }
    curl_close($curl);
  }
?>
</div>
  • 写回答

1条回答 默认 最新

  • dongmi1663 2018-11-13 08:09
    关注

    try this one bro

            echo $value['name'].' ';
            echo $value['txt'].' ';
            echo $value['_auc']['id'].'<br>';
            @ob_flush(); @flush();
    
    评论

报告相同问题?

悬赏问题

  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 正弦信号发生器串并联电路电阻无法保持同步怎么办
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 个人网站被恶意大量访问,怎么办
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)