code: public static function arrayPathGet($array, $path)
      {
          if (!\is_array($path)) {
              $path = \array_filter(\preg_split('#[\./]#', $path), 'strlen');
          }
          $path = \array_reverse($path);
          while ($path) {
              $key = \array_pop($path);
              $arrayAccess = \is_array($array) || $array instanceof \ArrayAccess;
              if (!$arrayAccess) {
                  return null;
              } elseif (isset($array[$key])) {
                  $array = $array[$key];
              } elseif ($key == '__count__') {
                  return \count($array);
              } elseif ($key == '__end__') {
                  \end($array);
                  $path[] = \key($array);
              } elseif ($key == '__reset__') {
                  \reset($array);
                  $path[] = \key($array);
              } else {
                  return null;
              }
          }
          return $array;
      }
docs: Get value from array
  
  @param array        $array array to traverse
  @param array|string $path  key path
  path may contain special keys:
  * __count__ : return count() (traversal will cease)
  * __end__ : last value
  * __reset__ : first value
  
  @return mixed