> The problem is this. The Values are formatted like this...
>
> value1|value2|value3...etc...
>
> I use the strstr() function to check against the $default so I can check
> it
> if so.
>
> Well it works great..BUT, lets say the product has a category of "Coffee
> Pots", but the one of the values available is "Coffee".
>
> In this case both "Coffee" AND "Coffee Pots" get checked when only "Coffee
> Pots" should.
Personally, I wouldn't be passing in parameters with '|' as a delimiter in
the first place. I'd have everything being an array. What if some day
somebody *WANTS* | as part of their category? You're in deep trouble then.
You'll have to write a string parser not unlike PHP's string parser with
an escape charachter to allow for "|" to be in the string and that's a TON
of work for what should be dirt simple.
The easiest fix, keeping your code mostly the same would be:
if (strstr("|$default|", "|" . $values[$i]['id'] . "|")
The trick is to get | on the beginning and end of the whole string, and
then your "Coffee" will be guaranteed to have | on each side of it, so
then you can search specifically for "|Coffee|" as a single term, and not
be fooled by "|Coffee Pot|" which is a different term.
Hope that helps.
--
Like Music?
http://l-i-e.com/artists.htm
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php