Re: Wildcard fromURL

From: Date: Thu, 13 Mar 2003 21:10:15 +0000
Subject: Re: Wildcard fromURL
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-139596@lists.php.net to get a copy of this message
At 21:55 13-3-2003, you wrote:
mod.php?mod=userpage&menu=215&page_id=xxx mod.php?mod=userpage&menu=20001&page_id=xxx mod.php?mod=site_map&menu=20010 And would want all the following pages to load an image named something like foo_1.jgp mod.php?mod=userpage&menu=1&page_id=xxx submit.php&menu=100 mod.php?mod=userpage&menu=10002&page_id=xxx In all cases, I know for sure that in the URL I will find menu=x* Can I set something up like; if(menu = '2*') { $ImgNo = '2'; } if(menu = '1*') { $ImgNo = '1'; } if(menu = '') { $ImgNo = '3'; }
To read the value of menu in the url, do not use 'menu', but use
$_GET['menu']      (since PHP 4.1.0)
To check for '2*' you cannot do what you propose. Because PHP is such a friendly language with 'types' you could use a string function to pick the first character $img_pick=subtr($_GET['menu'],0,1); (check the manual on substr() to be sure, in the online manual on www.php.net) The maximum of numbers is 10 (0-9), so you may want to just make a separate value in the url for this. I thionk you can omit the if-list now.
echo = "<img src=\"foo_$imgNo.jpg\">";


« previous php.general (#139596) next »