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 给自己本科IT专业毕业的妹m找个实习工作
  • ¥15 用友U8:向一个无法连接的网络尝试了一个套接字操作,如何解决?
  • ¥30 我的代码按理说完成了模型的搭建、训练、验证测试等工作(标签-网络|关键词-变化检测)
  • ¥50 mac mini外接显示器 画质字体模糊
  • ¥15 TLS1.2协议通信解密
  • ¥40 图书信息管理系统程序编写
  • ¥20 Qcustomplot缩小曲线形状问题
  • ¥15 企业资源规划ERP沙盘模拟
  • ¥15 树莓派控制机械臂传输命令报错,显示摄像头不存在
  • ¥15 前端echarts坐标轴问题