我正在将以下查询字符串传递给PHP方法
searchFilterKeyword=ff&searchFilterDateEntered=07%2F29%2F2019&searchFilterStatus=1&searchFilterQuarantineStatus=&searchFilterSize=&searchFilterKennel=&searchFilterType=
我将如何explode
来生成以下数组:
[
'searchFilterKeyword' => 'ff',
'searchFilterDateEntered' => '07%2F29%2F2019',
'searchFilterStatus' => 1,
'searchFilterQuarantineStatus' => '',
'searchFilterSize' => '',
'searchFilterKennel' => '',
'searchFilterType' => ''
];
我还必须重新格式化日期以删除%2F
。我必须做所有这一切,因为我无法将new FormData()
对象传递到
{
'action': 'test',
'type': 'test',
'data': new FormData()
}
答案 0 :(得分:2)
您可以使用PHP的toFuture()
方法来完成它。
此方法接受两个
parse_str(string, array)
。第一个是字符串 您要解析的另一个是存储数组 解析的字符串。
parameters
输出:
$arr = [];
$queryStr = 'searchFilterKeyword=ff&searchFilterDateEntered=07%2F29%2F2019&searchFilterStatus=1&searchFilterQuarantineStatus=&searchFilterSize=&searchFilterKennel=&searchFilterType=';
parse_str($queryStr, $arr);
print_r($arr);
答案 1 :(得分:2)
要将查询字符串隐藏到数组中,可以使用parse_str
:
library ieee;
use ieee.std_logic_1164.all;
entity stck_ovflw is
port
(
a : in std_logic;
c : in std_logic;
b : out std_logic
);
end entity;
architecture rtl of stck_ovflw is
begin
process(c)
begin
b <= a AND c;
end process;
end rtl;
其中$string = 'searchFilterKeyword=ff&searchFilterDateEntered=07%2F29%2F2019&searchFilterStatus=1&searchFilterQuarantineStatus=&searchFilterSize=&searchFilterKennel=&searchFilterType=';
$output = [];
parse_str($string, $output);
print_r($output);
是您的查询字符串,而$string
是一个空数组,其中填充了值