Page 1 of 1

Variable help

Posted: Tue Oct 12, 2010 3:27 am
by dezzik
Hi, I'm looking for a solution to my problems. I want to search a variable to see if it contains a certain string amongst others. This is basically what I mean:
Let's say

Code: Select all

$names = "Fred, Tom, Jill, Alex";
If I wanted to check if the variable contains "Alex" or not, how would I proceed?
EDIT: Sorry, I forgot strpos. :banghead: Please close this.

Re: Variable help

Posted: Tue Oct 12, 2010 7:34 am
by requinix
dezzik wrote:Hi, I'm looking for a solution to my problems.
Aren't we all?


What's probably better for you is to split the string into bits and search for the bit you want. strpos will give you a false positive with something like "red".