我有一个数组如下:
array:4 [
"tag" => "form"
"attr" => array:1 [
"class" => array:1 [
0 => "form-horizontal"
]
]
"text" => " "
"child" => array:1 [
0 => array:3 [
"tag" => "fieldset"
"text" => " "
"child" => array:1 [
0 => array:2 [
"tag" => "input"
"text" => "input name"
]
]
]
]
]
id喜欢重新创建一个新数组,如下所示
array[
0 => array[
"input" => "something",
"value" => "somevalue"
],
0 => array[
"input" => "something",
"value" => "somevalue"
]
]
if" tag" => "输入"
目前正在使用以下代码,基于laravel:
public function AjaxData(Request $request)
{
//
$array = $request->json;
debug($array);
$array2 = array_map(array($this, 'sanitize'), $test1 );
debug($array2);
return response()->json(['name' => $array['tag'] ]);
}
private function sanitize($value)
{
return $value['tag'];
}