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? Link to comment https://forums.phpfreaks.com/topic/228636-help-with-current-folder-subfolders-of-domain/ 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/ Link to comment https://forums.phpfreaks.com/topic/228636-help-with-current-folder-subfolders-of-domain/#findComment-1178878 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!'; } ?> Link to comment https://forums.phpfreaks.com/topic/228636-help-with-current-folder-subfolders-of-domain/#findComment-1179184 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. Link to comment https://forums.phpfreaks.com/topic/228636-help-with-current-folder-subfolders-of-domain/#findComment-1179295 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.