anthelo Posted February 23, 2011 Share Posted February 23, 2011 Hi, Im having this peace of code <?php $requested = empty($_SERVER['REQUEST_URI']) ? false : $_SERVER['REQUEST_URI']; switch ( $requested ) { case '/videos/': $content_title = 'Videos Home Directory'; break; default: $content_title = 'Welcome to my Website!'; } ?> What im trying to do is when im on the domain www.mydomain.com will show $content_title . My problem is when im trying for example www.mydomain.com/videos/ everything is ok but when im on www.mydomain.com/videos/something_else/ I want the the same title again Any help please? Quote Link to comment Share on other sites More sharing options...
btherl Posted February 23, 2011 Share Posted February 23, 2011 Try this: $requested_parts = explode('/', $requested); print "Element 1 is {$requested_parts[1]}<br."; That should show "videos" when you are at /videos/, and also when you are at /videos/something_else/ Quote Link to comment Share on other sites More sharing options...
anthelo Posted February 24, 2011 Author Share Posted February 24, 2011 not working This is what my code now is look like. <?php $requested_parts = explode('/', $requested); $requested = empty($_SERVER['REQUEST_URI']) ? false : $_SERVER['REQUEST_URI']; switch ( $requested_parts ) { case '/videos/': $content_title = 'Videos Home Directory'; break; default: $content_title = 'Welcome to my Website!'; } ?> Quote Link to comment Share on other sites More sharing options...
btherl Posted February 24, 2011 Share Posted February 24, 2011 You need to set $requested before you use explode() on it. Switch the order of the first two lines. Also $requested_parts[1] is what you need to look at, not $requested_parts. And the value to compare against is "videos", not "/videos/", because explode() will remove all the slashes. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.