original_string: public static function findElementsByKey($array, $key, &$targetArray = null, $prefix = "") {
  
          if ($array instanceof AssociativeArray) {
              $array = $array->toArray();
          }
  
          if (!$targetArray)
              $targetArray = array();
  
          foreach ($array as $itemKey => $value) {
  
              if ($itemKey === $key) {
                  $targetArray[substr($prefix . "." . $key, 1)] = $value;
              } else if (is_array($value) || $value instanceof AssociativeArray) {
  
                  if (is_numeric($itemKey)) {
                      $newPrefix = $prefix . "[" . $itemKey . "]";
                  } else {
                      $newPrefix = $prefix . "." . $itemKey;
                  }
  
                  ArrayUtils::findElementsByKey($value, $key, $targetArray, $newPrefix);
              }
          }
  
          return $targetArray;
  
      }
code: public static function findElementsByKey($array, $key, &$targetArray = null, $prefix = "") {
  
          if ($array instanceof AssociativeArray) {
              $array = $array->toArray();
          }
  
          if (!$targetArray)
              $targetArray = array();
  
          foreach ($array as $itemKey => $value) {
  
              if ($itemKey === $key) {
                  $targetArray[substr($prefix . "." . $key, 1)] = $value;
              } else if (is_array($value) || $value instanceof AssociativeArray) {
  
                  if (is_numeric($itemKey)) {
                      $newPrefix = $prefix . "[" . $itemKey . "]";
                  } else {
                      $newPrefix = $prefix . "." . $itemKey;
                  }
  
                  ArrayUtils::findElementsByKey($value, $key, $targetArray, $newPrefix);
              }
          }
  
          return $targetArray;
  
      }
code_tokens: public static function findElementsByKey ( $ array , $ key , & $ targetArray = null , $ prefix = "" ) { if ( $ array instanceof AssociativeArray ) { $ array = $ array -> toArray ( ) ; } if ( ! $ targetArray ) $ targetArray = array ( ) ; foreach ( $ array as $ itemKey => $ value ) { if ( $ itemKey === $ key ) { $ targetArray [ substr ( $ prefix . "." . $ key , 1 ) ] = $ value ; } else if ( is_array ( $ value ) || $ value instanceof AssociativeArray ) { if ( is_numeric ( $ itemKey ) ) { $ newPrefix = $ prefix . "[" . $ itemKey . "]" ; } else { $ newPrefix = $ prefix . "." . $ itemKey ; } ArrayUtils :: findElementsByKey ( $ value , $ key , $ targetArray , $ newPrefix ) ; } } return $ targetArray ; }
docstring: Find elements by key.
  
  @param $array
  @param $key
docstring_tokens: Find elements by key .