dongtou2097 2012-12-29 15:05
浏览 27
已采纳

表单元素名称中的zend方括号

I have one problem with Zend Framework. I included into my form MultiCheckbox element and it adds square brackets to it's name in HTML(for example I need element with name tags, but ZF makes it tags[]).

When I use this form in my home development server everything just works fine. But then I uploaded code to production server it just went wrong. When putting to database I have to make column named tags[] and because php uses square brackets for arrays everything crashes and I can't use it in my view.

How could I solve this problem?

  • 写回答

1条回答 默认 最新

  • donglun7151 2012-12-29 17:12
    关注

    Square braquets is the normal way to define an array for data used with $_GET and $_POST methods.

    In your PHP script, you need to unserialize the array and parse or do what you want with your array.

    <?php 
        //Example for $_REQUEST["item"] = "item[]=1&item[]=2"
    
        $arr = unserialize($_REQUEST["item"]); 
        foreach($arr as $index => $position)
        {
            //Do what you want
        }
    ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 请问如何在openpcdet上对KITTI数据集的测试集进行结果评估?
  • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow
  • ¥20 有人知道这种图怎么画吗?
  • ¥15 pyqt6如何引用qrc文件加载里面的的资源
  • ¥15 安卓JNI项目使用lua上的问题
  • ¥20 RL+GNN解决人员排班问题时梯度消失
  • ¥60 要数控稳压电源测试数据
  • ¥15 能帮我写下这个编程吗
  • ¥15 ikuai客户端l2tp协议链接报终止15信号和无法将p.p.p6转换为我的l2tp线路
  • ¥15 phython读取excel表格报错 ^7个 SyntaxError: invalid syntax 语句报错