Skip to content

Instantly share code, notes, and snippets.

@m4rw3r
Created August 6, 2011 15:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save m4rw3r/1129440 to your computer and use it in GitHub Desktop.
Save m4rw3r/1129440 to your computer and use it in GitHub Desktop.
<?php
function($url)
{
$matches = array();
if(isset($url[0]) && $url[0] == "/")
{
if(isset($url[1]) && $url[1] == "u")
{
if(isset($url[2]) && $url[2] == "s" && isset($url[3]) && $url[3] == "e" && isset($url[4]) && $url[4] == "r")
{
if(preg_match('/\\/user(?:\\/(?<id>\\d+))?/', $url, $matches))
{
return array(array(2), $matches);
}
if(isset($url[5]) && $url[5] == "-")
{
if(isset($url[6]) && $url[6] == "p" && isset($url[7]) && $url[7] == "r" && isset($url[8]) && $url[8] == "o" && isset($url[9]) && $url[9] == "f" && isset($url[10]) && $url[10] == "i" && isset($url[11]) && $url[11] == "l" && isset($url[12]) && $url[12] == "e" && isset($url[13]) && $url[13] == "/" && preg_match('/\\/user\\-profile\\/(\\d+)/', $url, $matches))
{
return array(array(3), $matches);
}
}
return array(array(1), $matches);
}
}
return array(array(0), $matches);
}
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment