When this happens to me I always just echo the variable value like so to see if something is there that shouldn't be:
echo "cccc"; echo "$id"; echo "cccc"; obviously all this does is print the variable with a bunch of c's before and after. That way I can see if there are any extra things included with the value that shouldn't be there. Then use the trim() commands as someone else mentioned. Roger Geoff Caplan wrote: > Hi folks, > > A strange one - unless I am having a brainstorm... > > I am reading in tab delimited files created in Excel on Windows and > uploaded to Linux. > > Cell A1 contains a numeric id - I extract this into a variable, $id, > by exploding on \n and \t. > > But for some files, the values of $id do not behave as expected. Say > the value should be "23". > > If I echo, it prints as "23". But comparisons fail to match: > > if( $id == 23 ) ... > > It also fails if I try to find the value as a key in an > array: > > if( isset( $my_array[$id] ) ) ... > > On the other hand, values from some of the files work as expected. > > One clue: if I try and cast the values that are failing to int, the > cast produces the value 0 (zero). On the other hand, the values that > are working as expected cast from, say, the string 22 to the int 22 as > expected. > > Never seen anything like this before - can anyone give me a pointer?? > > -- > > Geoff Caplan > Advantae Ltd > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php