【问题标题】:Nested ID from the url needed来自所需网址的嵌套 ID
【发布时间】:2012-08-29 15:58:17
【问题描述】:

我需要得到一个ID,它显示在URL 中。 我可以通过在php 中使用$_GET 来访问ID's,但是当它们如下例所示嵌套时,我无法获得ID...

示例:

index.php?id[sub1]=1789&id[sub2]=1789

如果有人可以帮助使用phpjQuery 寻求解决方案,我将非常高兴。

【问题讨论】:

标签: php jquery url


【解决方案1】:

假设 ID 始终相同:

if (isset($_GET['id'])) {
    $id = is_array($_GET['id']) ? current($_GET['id']) : $_GET['id'];
}

【讨论】:

    【解决方案2】:
    <?php
    $str="index.php?id[sub1]=1789&id[sub2]=1789";
    
    $x=parse_str($str,$out);
    
    
    print_r($out); //loop through this
    
    Array
    (
        [index_php?id] => Array
            (
                [sub1] => 1789
            )
    
        [id] => Array
            (
                [sub2] => 1789
            )
    
    )
    

    【讨论】:

      猜你喜欢
      • 2018-10-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-02-11
      • 2021-08-26
      • 2012-05-05
      • 2011-07-10
      • 2019-03-26
      相关资源
      最近更新 更多