Php 如何正确获取和打印给定URL参数的值

Php 如何正确获取和打印给定URL参数的值,php,arrays,geturl,Php,Arrays,Geturl,我有一个带有参数的链接: 我希望得到所有的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_fie

我有一个带有参数的链接:

我希望得到所有的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

所有参数都将被忽略,它们在URL中必须是唯一的 尝试这种方法http://example.com/article?id=571,550,276


这不好。您需要使用get中的唯一键,并且您可以使用$\u get或使用带分隔符的一个参数传递它。在您的情况下,$\u GET['id']值将始终是url中的最后一个ids值。
if(isset($_GET['id'])){
print $_GET['id'];
}