Hello I was wondering how i can getsometing from the url into a variable ? let's say i have this url http://domain.com/1726 now i want 1726 into $number. How can this be done ?? it should be for anyting that comes after the /
ok, but if the number is someting else, it varies? 1726 for now, then next time the page is loaded it's 1912 etc.
basename will get anything after last trailing slash. If you want to work on the Current url, then $number = basename('http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']); PHP:
i found another question now i need to ask. this is my current code. <body bgcolor="Black"> <? include 'head.php'; ?> <? $number = basename('http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']); ?> <center> <div id="flashloop"> <object type="application/x-shockwave-flash" data="<? echo "/flash/loops/".basename($number).""; ?>.swf" width="640" height="480"> <param name="autostart" value="true" /> <param name="src" value="<? echo "/flash/loops/".basename($number).""; ?>.swf" /> </object> </div> </center> <center> Code (markup): now, if i link mydomain.com/index.php/765 $number ofcourse becomes 765. BUT, if link mydomain.com/index.php/ can we make it put someting after the / by default if there is nothing there ?
let's say if there is nothing there after the / i want it to default to to 1. so it becomes mydomain.com/index.php/1
$number = basename('http://'.$_SERVER['HTTP_HOST'].($_SERVER['REQUEST_URI'] == '/' ? 1 : $_SERVER['REQUEST_URI'])); PHP: