underscore-php
underscore-php copied to clipboard
group array by key value
I tried using the group array helper/method as below :
*The array *
mainarray => [
0 => array [
"value" => "option1"
"placeholder" => ""
"text" => ""
"name" => "optionsRadios"
"id" => ""
"class" => ""
"label" => "Option Three "
]
1 => [
"value" => "option2"
"placeholder" => ""
"text" => ""
"name" => "optionsRadios"
"id" => ""
"class" => ""
"label" => "Option Three "
]
2 => [
"value" => "option3"
"placeholder" => ""
"text" => ""
"name" => "optionsRadios"
"id" => ""
"class" => ""
"label" => "Option Three "
]
]
function
Arrays::group($mainarray, function($value) {
return $value['name'] == 'optionsRadios'; // test key value
})
i keep getting error , how would i achive this ?