Is there a PHP function that can match anything after the given URL, so my IF statement will work in each instance?

look for the string page/ and capture just the part of the url before it with strpos and substr:

$url="/players/type/pros/page/3/";
$find = 'page/';
$trimmed_url = substr( $url, 0, strpos($url, $find) );

EDIT – so in the context of your question you could use:

$url = $_SERVER['REQUEST_URI'];
$find   = 'page/';
$pos = strpos($url, $find);
if($pos):
    $url = substr($url, 0, $pos);
endif;

if( $url == '/players/type/pros/' ){
    //run the query to list the pros
}

But a question I have – why are you using the URL to determine what to load, can you not check $_GET[‘type’] or whatever query vars are being set?

Leave a Comment

error code: 523