Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What kind of IF options are there? 1

Status
Not open for further replies.

mufka

ISP
Dec 18, 2000
587
US
I need to look at a variable to see whether it contains within it another variable.

Something like "IF $var1 CONTAINS $var2"
In this case if $var1=hellothere and $var2=there, it would be true.

Is there some way I can do this?

Thanks
 
mufka:
Be sure to read completely the online manual page entry for strpos(). There is a warning there about possible logic errors that come up between the function's returning a 0 (if the searched-for string is at the beginning of the haystack) and the function's returning a FALSE (if the searched-for string is not in the haystack at all).



Want the best answers? Ask the best questions! TANSTAAFL!
 
My haystack is $HTTP_REFERER and what I'm looking for is near the end. I'm checking to see if the result of strpos is > 0. If it is or if the needle variable is empty, it just leaves the variable for $HTTP_REFERER unchanged. If strpos is 0 or if the needle variable is not empty, I append something to the $HTTP_REFERER.

What I'm doing is linking from a query page and I need to send the query data back to the query script if I link back to it from the destination page. I'm using one destination page that can be reached from either the query script of a static page. Rather than having two different pages, I wanted to put logic in to take different action if the referrer was a query page.

You probably don't want to know all that, but I don't think I need to worry about the stated concerns. I've tried every combination of ins and outs from the pages and I've had no anomalies.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top