Exemplo n.º 1
0
 function test_where()
 {
     $array = array('a' => 1, 'b' => 2, 'c' => 3, 'd' => 4, 'e' => 5, 'f' => 6, 'g' => 7, 'h' => 8);
     $this->assertEquals(array('b' => 2, 'd' => 4, 'f' => 6, 'h' => 8), Arr::where($array, function ($key, $value) {
         return $value % 2 === 0;
     }));
     $this->assertEquals(array('c' => 3, 'f' => 6), wpdevsclub_array_where($array, function ($key, $value) {
         return $value % 3 === 0;
     }));
 }
Exemplo n.º 2
0
 /**
  * Filter the array using the given Closure.
  *
  * @param  array     $array
  * @param  \Closure  $callback
  * @return array
  */
 function wpdevsclub_array_where($array, Closure $callback)
 {
     return Arr::where($array, $callback);
 }