Page 1 of 1
Comparing Strings
Posted: Sat Dec 17, 2011 6:48 am
by spacebiscuit
I'm comparing two strings, although they appear to be the same when I do a var)_dump they are not:
Code: Select all
string(71) "blah blah" string(96) "blah blah
Note that the closing quotation is missing from the second string. I've tried trim but this doesn't seem to work.
Any ideas?
Thanks.
Re: Comparing Strings
Posted: Sat Dec 17, 2011 7:20 am
by phpHappy
not real sure what you want - if you want to know they are different in code -several ways to
if($str[71] == $str[96]) { your code if they are the same }
else { echo '"$str[71]" does not equal "$str[96]"';}
Re: Comparing Strings
Posted: Sun Dec 18, 2011 5:03 am
by spacebiscuit
Ok I figured out the problem - I was using regex to populate the variables that were passed via the form. The regex had an error and unwanted characters were being matched, I fixed the regex and now it works.
Thanks for your help!