You are here

private function ResourceReadOnlyStreamWrapper::_parse_url in D7 Media 6

Returns an array of any parameters stored in the URL's path.

Parameters

$url: The URL to parse, such as youtube://v/[video-code]/t/[tags+more-tags]. @return An associative array of all the parameters in the path, or FALSE if the $url is ill-formed.

1 call to ResourceReadOnlyStreamWrapper::_parse_url()
ResourceReadOnlyStreamWrapper::stream_open in resource/ResourceReadOnlyStreamWrapper.inc
Support for fopen(), file_get_contents(), file_put_contents() etc.

File

resource/ResourceReadOnlyStreamWrapper.inc, line 58

Class

ResourceReadOnlyStreamWrapper
A base class for Resource Stream Wrappers.

Code

private function _parse_url($url) {
  $path = parse_url($url, PHP_URL_PATH);
  if ($path === FALSE) {

    // Non-recoverable error when parsing the path.
    return FALSE;
  }
  $parts = explode('/', $path);
  $params = array();
  $count = 0;
  $total = count($parts);
  if (!$total || $total % 2) {

    // If we have no parts, or an odd number of parts, it's malformed.
    return FALSE;
  }
  while ($count < $total) {

    // We iterate count for each step of the assignment to keep us honest.
    $params[$parts[$count++]] = $parts[$count++];
  }
  return $params;
}