如何通过一个数组中得到PHP? [英] how to pass an array in GET in PHP?

查看:101
本文介绍了如何通过一个数组中得到PHP?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

$idArray = array(1,2,3,4);

我可以写在HTML这一行?

can I write this line in HTML?

<form method='POST' action='{$_SERVER['PHP_SELF']}?arr={$idArray}'>

或者我应该写:

<form method='POST' action='{$_SERVER['PHP_SELF']}?arr[]={$idArray}'>

如何将它传递?

我应该怎么处理它在叫页面?

how should I handle it in the called page?

谢谢!

推荐答案

如果你想传递一个数组作为参数,你就必须添加参数为每个元素。您的查询字符串将变成:

If you want to pass an array as parameter, you would have to add a parameter for each element. Your query string would become:

?arr[]=1&arr[]=2&arr[]=3&arr[]=4

正如其他人写的,你也可以的连载的和的反序列化的数组。

但你真的需要再次进行数据发送到客户端?它看起来像你只需要一种方法来的请求间维持数据的。

But do you really have to send the data to the client again? It looks like you just need a way to persist the data between requests.

在这种情况下,最好是伊莫使用<一href=\"http://php.net/manual/en/features.sessions.php\">sessions(docs).这也更安全的,因为否则客户端可以修改数据

In this case, it is better imo to use sessions(docs). This is also more secure as otherwise the client could modify the data.

这篇关于如何通过一个数组中得到PHP?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆