3
我需要獲得顯示在URL
中的ID
。 我可以在php
使用$_GET
訪問ID's
但它們嵌套時,如在下面的例子中我不能讓不能ID
...來自所需url的嵌套ID
例如:
index.php?id[sub1]=1789&id[sub2]=1789
我如果有人可以幫助使用php
或jQuery
獲得解決方案,將非常高興。
我需要獲得顯示在URL
中的ID
。 我可以在php
使用$_GET
訪問ID's
但它們嵌套時,如在下面的例子中我不能讓不能ID
...來自所需url的嵌套ID
例如:
index.php?id[sub1]=1789&id[sub2]=1789
我如果有人可以幫助使用php
或jQuery
獲得解決方案,將非常高興。
假設ID始終是相同的:
if (isset($_GET['id'])) {
$id = is_array($_GET['id']) ? current($_GET['id']) : $_GET['id'];
}
<?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
)
)
'的index.php ID [] = 1789&ID [] = 1789'應該沒有密鑰工作,那麼ID應是一個有效的陣列在$ _GET,不知道如果我得到你正確 – Hawili
請檢查此[http://stackoverflow.com/questions/3093100/how-to-send-array-values-through-url-in-php](http:/ /stackoverflow.com/questions/3093100/how-to-send-array-values-through-url-in-php) – Hawili
怎麼樣,'echo $ _GET ['id'] ['sub1'];''和'echo $ _GET [ '身份證'] [ 'SUB2'];' – Brett