doufen3134 2014-07-27 17:32
浏览 36
已采纳

php for循环冻结循环时

When I tried to get variables while looping it just froze my screen and I got following error:

Fatal error: Maximum execution time of 30 seconds exceeded in /home/diligenceh/domains/diligencehelps.com/public_html/upload_lesson.php on line 16

The loop:

$lesson_count       = preg_replace('#[^0-9]#', '', $_POST['description_count']);
for($i = 1; $i <= $lesson_count; $i++)
{
    $image_url_ + $i = $_POST['image_url_'+ $i];
    echo $image_url_ + $i;
}
  • 写回答

4条回答 默认 最新

  • doumiang0597 2014-07-27 22:12
    关注

    I think that your code must be something like this:

    $_POST['description_count'] = preg_replace('#[^0-9]#', '', $_POST['description_count'], -1, $lesson_count);
    
    for($i = 1; $i <= $lesson_count; $i++) {
        echo  $_POST['image_url_'.$i];
    }
    

    pay atention in following:

    1.- The 4th parameter in preg_replace() contain the number of replacements made.

    2.- The function preg_replace return the original string with the changes. Read the manual here: http://cl1.php.net/manual/en/function.preg-replace.php

    3.- I don't understand that what are you trying to do here:

    $image_url_ + $i = $_POST['image_url_'+ $i];
    

    you are using plus symbol (+) instead dot (.) to concatenate strings.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料