if URL = "Entire Directory"?

Discussion in 'PHP' started by PFCritics, Jun 22, 2006.

  1. #1
    I'm sort of new to PHP; here's my question:
    Is there a way I can say "if $variable == "entiredir.."?

    Here's a small piece of my code to better explain:

    <?php $theuri = $_SERVER['REQUEST_URI'];
    	if ( ($theuri =="/gr/gamecube..") or ($theuri =="/gr/gc.php") ) {
    	$itemis = "gc"; }
    
    	else {
    	$itemis = ""; }
    
    ?>
    PHP:
    Notice the part that says "/gr/gamecube..". I want this to mean that ALL files beyond this URL will apply the same function. So, pages with /gr/gamecube/weee.php, /gr/gamecube/beyond/yay.php, gr/gamecube/beyond/beyond/ooo.php would ALL apply the same function.

    Is this possible with PHP, and if so, how? :) It'd be much more convienant than listing every single page...
     
    PFCritics, Jun 22, 2006 IP
  2. themole

    themole Peon

    Messages:
    82
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #2
    This should work:

    
    
    <?php 
    
    	$theuri = $_SERVER['REQUEST_URI'];
    
    	if ( eregi('/gr/gamecube', $theuri) || eregi('/gr/gc.php', $theuri))
    		$itemis = "gc"; 
    
    	else
    		$itemis = "";
    
    ?>
    
    
    PHP:

    -the mole
     
    themole, Jun 22, 2006 IP
  3. PFCritics

    PFCritics Peon

    Messages:
    107
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks a lot! Works perfectly :D
     
    PFCritics, Jun 23, 2006 IP