【发布时间】:2014-10-22 12:28:42
【问题描述】:
我有这个带参数的链接:
http://example.com/article?id=571&id=550&id=276
我希望获取所有的 id 值,形成一个数组并输出到一个字段,我尝试了几种方法但都没有奏效,有人可以帮忙吗?谢谢
if (isset($_GET['id'])){
// create an array to store all ids from the parameter
// Output each values in the array to $string variable
$form['submitted']['my_field']['#value'] = $string; // output all ids via this field.
}; //endif ;
我希望它会在场上这样输出:“571,550,276”
【问题讨论】:
-
这不好。您需要使用 get 中的唯一键,并且您可以使用
$_GET或使用带有分隔符的一个参数传递它。在你的情况下,$_GET['id']值将始终是 url 中的最后一个 ids 值。