Home > Backend Development > PHP Tutorial > 怎么用数组去接受这一系列参数

怎么用数组去接受这一系列参数

WBOY
Release: 2016-06-13 13:24:08
Original
1107 people have browsed it

如何用数组去接受这一系列参数?
用jquery异步向B页面传递一系列参数:
 $.get('get.php?a="+ Math.random()', {name: $(this).val()}, function(data) {
  alert(unescape(data));
});
其中$(this).val()为一组数据,其值为1,2,3,4 通过jquery 的$.get方法向B页面传这组数据,如何在B页面用数组接收这组数据并用数组的索引显示出来,比如echo $name[1]就可以打印出2。

------解决方案--------------------
$_GET['name'] = '1,2,3,4';

$arr = explode(',', $_GET['name']);
print_r($arr);

//输出结果
Array
(
[0] => 1
[1] => 2
[2] => 3
[3] => 4
)

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template