Jump to content

Find String within URL


dtyson2000

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/204251-find-string-within-url/
Share on other sites

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!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.