Skip to content

Instantly share code, notes, and snippets.

@m4rw3r m4rw3r/gist:1129440
Created Aug 6, 2011

Embed
What would you like to do?
<?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
You can’t perform that action at this time.