[英]Get form serialize value from the array list
I have an array like this:我有一个这样的数组:
Array
(
[action_name] => edit
[formData] => color=red&size=full&symmetry=square
)
Here, form data is coming using the serialize method of JS and so it is displayed like above.在这里,表单数据是使用JS的serialize方法来的,所以显示如上。 I want to get each data from the
formData
key.我想从
formData
键中获取每个数据。 How can I get that?我怎么能得到那个?
I tried:我试过了:
$_POST['formData']['color']
But that is not working.但这行不通。 I think the method to fetch this shall be different.
我认为获取这个的方法会有所不同。 How can I do that?
我怎样才能做到这一点?
You can use parse_str to " parse string as if it were the query string passed via a URL and sets variables in the current scope (or in the array if result is provided). "您可以使用parse_str来“解析字符串,就像它是通过 URL 传递的查询字符串一样,并在当前 scope 中设置变量(如果提供了结果,则在数组中)。 ”
<?php
$myArray = [
"action_name" => "edit",
"formData" => "color=red&size=full&symmetry=square",
];
parse_str($myArray['formData'], $parsed);
print_r($parsed);
will output将 output
Array
(
[color] => red
[size] => full
[symmetry] => square
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.