original_string: protected function pregGrepRecursive($pattern, $haystack)
      {
          $matches = [];
          
          foreach ($haystack as $key => $item) {
              if (is_array($item)) {
                  $sub_matches = $this->pregGrepRecursive($pattern, $item);
                  
                  if ($sub_matches) {
                      $matches[$key] = $sub_matches;
                  }
              } elseif (preg_match($pattern, $item)) {
                  $matches[$key] = $item;
              }
          }
          
          return $matches;
      }
code: protected function pregGrepRecursive($pattern, $haystack)
      {
          $matches = [];
          
          foreach ($haystack as $key => $item) {
              if (is_array($item)) {
                  $sub_matches = $this->pregGrepRecursive($pattern, $item);
                  
                  if ($sub_matches) {
                      $matches[$key] = $sub_matches;
                  }
              } elseif (preg_match($pattern, $item)) {
                  $matches[$key] = $item;
              }
          }
          
          return $matches;
      }
code_tokens: protected function pregGrepRecursive ( $ pattern , $ haystack ) { $ matches = [ ] ; foreach ( $ haystack as $ key => $ item ) { if ( is_array ( $ item ) ) { $ sub_matches = $ this -> pregGrepRecursive ( $ pattern , $ item ) ; if ( $ sub_matches ) { $ matches [ $ key ] = $ sub_matches ; } } elseif ( preg_match ( $ pattern , $ item ) ) { $ matches [ $ key ] = $ item ; } } return $ matches ; }
docstring: Recursive version of preg_grep.
  
  @param  string  $pattern
  @param  array  $haystack
  @return array
docstring_tokens: Recursive version of preg_grep .