dtyson2000 Posted June 9, 2010 Share Posted June 9, 2010 Hello. I'd like to find a string within the current URL and if it returns true, run an action. This is what I have so far: $url = $_SERVER["REQUEST_URI"]; $find = "text"; if (strpos($url, $find)) { action; } else { another action; } Gosh am I even shooting in the right direction? Any thoughts? Quote Link to comment https://forums.phpfreaks.com/topic/204251-find-string-within-url/ Share on other sites More sharing options...
dabaR Posted June 9, 2010 Share Posted June 9, 2010 Hi there. Ya, basically you were on the right path, if not all the way there... See example code here: http://codepad.org/rWLr4v9E Quote Link to comment https://forums.phpfreaks.com/topic/204251-find-string-within-url/#findComment-1069764 Share on other sites More sharing options...
dtyson2000 Posted June 9, 2010 Author Share Posted June 9, 2010 Thank you very much for verifying what I was doing. I was at a bit of a loss because things weren't working out the way I wanted. I found out that it was because the php I needed is inside an iFrame and it wasn't calling the URL of the parent page. Instead, it calls its own URL. When I actually search for a string within the URL for the iFrame, it works perfectly. Still haven't been able to grab the URL of the parent page and based on my old friend Google, I'm not sure that it's going to be possible to get because the parent page (on the same host and part of same site) has a .html extension (over which I have no control - they want it to remain html) so I can't just pass the variable via PHP from parent to iFrame. I'll keep searching for a solution. But thank you again for your quick and accurate reply! Quote Link to comment https://forums.phpfreaks.com/topic/204251-find-string-within-url/#findComment-1069884 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.