groovygarden
Programmer
- Aug 23, 2001
- 63
Hiya,
I'm trying to compare two strings. One is an array, $list, generated from a select statement, the other is a value, $selected, which holds the value a user has chosen from a <select> drop down.
$list[$i]==$selected
Problem is, even when the strings should match, they don't.
The strings are exactly the same, except that spaces in the string are encoded differently. Someone helpfully suggested I use the ord function and it turns out that in $selected spaces are encoded with 160 where as in $list the code is 32.
Am I right in thinking this is why the strings don't match even though they echo the "same". What can I do to change the way spaces are encoded or can anyone think of a way round this?
Any suggestions much appreciated
Thanks
I'm trying to compare two strings. One is an array, $list, generated from a select statement, the other is a value, $selected, which holds the value a user has chosen from a <select> drop down.
$list[$i]==$selected
Problem is, even when the strings should match, they don't.
The strings are exactly the same, except that spaces in the string are encoded differently. Someone helpfully suggested I use the ord function and it turns out that in $selected spaces are encoded with 160 where as in $list the code is 32.
Am I right in thinking this is why the strings don't match even though they echo the "same". What can I do to change the way spaces are encoded or can anyone think of a way round this?
Any suggestions much appreciated
Thanks