On 12/21/2012 4:38 PM, Tedd Sperling wrote:
Hi gang;

I just ran into something I have never had a problem with before.

Here's the code:

--- start of code

        $topic = '';
        while($row = mysql_fetch_array($result))  // pulling stuff from a 
database
                {
                $topic .= $row['category'] . '~';       // adding a delimiter 
between categories
                }
                                
        $str_length = strlen($topic);
        if($topic[$str_length-1] == '~')
                {
                $topic[$str_length-1] = '';     // remove last ~ delimiter
                }

        echo($topic);   // this result is used in an AJAX script

--- end of code

Now, when the result is displayed (i.e., echoed) to Javascript routines running 
in Safari and FireFox, everything is OK.

But when the result is displayed on IE, the "end" of the string causes problems 
with the exact same javascript routine as used above.

Now, I realize that I have altered the string by removing the last character 
and I have not shortened the string to reflect that, but I never thought it 
would cause any problems.

Would someone please enlighten me as to why this would work in Safari, FireFox, 
but not in IE?

Cheers,

tedd

PS:  Also, please don't beg the answer by saying "It's IE -- what do you 
expect?"

_____________________
t...@sperling.com
http://sperling.com

Never realized that you could address a string as an array of chars, which you are doing. Could that be the issue? Or did I learn something new? Or should you have used substr to remove that last char?

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to