This is my data:
$d = $request->request->get('data');
The output:
[{"name":"form[id]","value":"10"},{"name":"form[name]","value":"Telefon2"},{"name":"form[uuid]","value":"bb80878ad4"},{"name":"form[productgroup]","value":"6"},{"name":"form[category]","value":"1"},{"name":"form[documents]","value":"7"}
I want to create a new array, that is removing extracting the variable inside the brackets.
function trim($d) {
preg_match('#\[(.*?)\]#', $d, $match);
return $match[1];
}
$dData = array_combine(array_column(trim($d), 'name'), array_column($d, 'value'));
$json = json_encode($dData);
But the error is
Warning: preg_match() expects parameter 2 to be string, array given