underscore-php icon indicating copy to clipboard operation
underscore-php copied to clipboard

group array by key value

Open obonyojimmy opened this issue 8 years ago • 0 comments

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 ?

obonyojimmy avatar May 03 '16 18:05 obonyojimmy