Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static function parse_url($url)
- {
- $result = array();
- // Build arrays of values we need to decode before parsing
- $entities = array('%3A', '%40', '%26', '%3D', '%2F', '%3F', '%23', '%5B', '%5D');
- $replacements = array(":", "@", "&", "=", "/", "?", "#", "[", "]");
- // Create encoded URL with special URL characters decoded so it can be parsed
- // All other characters will be encoded
- $encodedURL = str_replace($entities, $replacements, urlencode($url));
- // Parse the encoded URL
- $encodedParts = parse_url($encodedURL);
- // Now, decode each value of the resulting array
- foreach ($encodedParts as $key => $value)
- {
- $result[$key] = urldecode($value);
- }
- return $result;
- }
Add Comment
Please, Sign In to add comment