网站综合信息 ashita.org
    • 标题:
    •  
    • 关键字:
    •  
    • 描述:
    •  
    • 域名信息
    •   
    • 备案信息
    • 备案号: 
    网站收录SEO数据
    • 搜索引擎
    • 收录量
    • 反向链接
    • 其他
    • 雅虎
    •  
    •  
    •  
    • 搜搜
    •  
    •  
    •  
    • 搜狗
    •  
    •  
    • 评级:-/10  
    • 360搜索
    •  
    •  
    •  
    域名流量Alexa排名
    •  
    • 一周平均
    • 一个月平均
    • 三个月平均
    • Alexa全球排名
    • -  
    • 平均日IP
    • 日总PV
    • 人均PV(PV/IP比例)
    • 反向链接
    • dmoz目录收录
    • -  
    • 流量走势图
    域名注册Whois信息

    ashita.org


    获取时间: 2014年09月19日 15:54:48
    WHOIS LIMIT EXCEEDED - SEE WWW.PIR.ORG/WHOIS FOR DETAILS
    同IP网站(同服务器)
  • 104.28.28.38 共1个网站 (北美地区)
  • ashita.org
  • 其他后缀域名
    • 顶级域名
    • 相关信息
    网站首页快照(纯文字版)
    抓取时间:2015年10月02日 10:55:59
    网址:http://ashita.org/
    标题:
    关键字:
    描述:
    主体:
    Skip to content
    Skip to menu
    Ashita.org
    Search
    HomeProjects
    Mar
    11
    2011
    Multi-dimensional and associative POST arrays
    Category: PHP — Jon @ 5:59 am
    Anyone doing web development requiring client-server interaction is familiar with GET and POST. (There are others as well, including PUT, DELETE, and so on. See http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html for the list.) And pretty quickly most folks become aware of the ability to pass arrays as request parameters. For example:
    <form method="post" action="http://www.example.com/myformproc.php">
    <fieldset>
    <legend>Notification Methods<legend>
    <input type="checkbox" name="note_opts[]" value="email" id="note_opt_email"><label for="note_opt_email">E-Mail</label>
    <input type="checkbox" name="note_opts[]" value="text" id="note_opt_text"><label for="note_opt_text">Text Message</label>
    ... etc ...
    </fieldset>
    </form>
    On the server side, if the user selected any of the notification options, you would have an array in a POST variable, ‘note_opts’. In PHP, for example you would see an array $_POST['note_opts']. That array would contain the values of the selected options. The indexes of those values would be numerically indexed in the usual, default, manner.
    What if we’re editing the options for multiple objects. Each of our objects has an id number and 0 or more of the options.
    What I often see is:
    
    <input type="checkbox" name="obj_<?php echo $object->getID(); ?>_note_opts[]" value="email" id="note_opt_email">
    And then we end up having to parse the id out of the variable name…
    Far better to do something like:
    
    <input type="checkbox" name="note_opts[<?php echo $object->getID(); ?>][]" value="email" id="note_opt_email">
    In this way we get a 2 dimensional array of note_opts. The object with id ’1′ is simply $_POST['note_opts'][1].
    This also makes it easy to loop through the objects getting their ids along the way
    $note_opts = $_POST['note_opts'];
    if (is_array($note_opts)) {
    foreach($note_opts as $obj_id=>$opt_set) {
    $obj = MyType::get($obj_id);
    if (!$obj) {
    addError("Failed to get object (".$obj_id.")";);
    } elseif (!$obj->setOptions($opt_set)) {
    addError("Failed to set options for ".$obj->getName()." (".$obj_id.")";);
    }
    }
    }
    It’s not a big leap from note_opts[] to note_opts[2][email_options][address]. Organizationally it makes life a lot easier, especially if there is any complexity to your data. This way hierarchical data can easily be represented in nested arrays. One final comment, please note that the named array indices like email_options and address are not enclosed in quotes.
    Comments (0)
    Mar
    11
    2011
    var self = this; huh?
    Category: JavaScript — Jon @ 4:40 am
    This is a subject that comes up frequently on StackOverflow. Some questions approach it from seeing it in code but not understanding why, while others approach it from the opposite si

    © 2010 - 2020 网站综合信息查询 同IP网站查询 相关类似网站查询 网站备案查询网站地图 最新查询 最近更新 优秀网站 热门网站 全部网站 同IP查询 备案查询

    2025-12-12 15:28, Process in 0.0062 second.