从jQuery序列化函数发送值获取PHP数组 [英] Get php array from jquery serialize function sended value

查看:104
本文介绍了从jQuery序列化函数发送值获取PHP数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我进行AJAX调用,并发送与表单的serialize-d值相等的参数.

I make a AJAX call, and sends the argument equal to forms's serialize-d value.

var form_data= $('#some-form').serialize();
var data = {
                    action: 'my-action',
                    data: form_data
                };
$.post(my-file.php,data...){...}

所以在我的php文件var中,我有一个$_POST['data'] = arg1=value1&arg2[arg2_1]=value2...,依此类推.

So in my php file var I have a $_POST['data'] = arg1=value1&arg2[arg2_1]=value2... and so on.

它可以是一个长字符串,具有无限数量的参数和无限深度级别.

It can be a long string with unlimited number of arguments and unlimited depth level.

所以问题-php中是否有任何函数可以将这样的字符串制作成这样的关联数组

So the question - is there any function in php, to make such string to an Associative array like this

$my_post[arg1]=value1;
$my_post[arg_2][arg2_1]=value2;
...

还是我需要自己编写该功能?

Or I need to write that function myself?

推荐答案

使用 parse_str() :

parse_str($_POST['data'], $my_post);

这篇关于从jQuery序列化函数发送值获取PHP数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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