Strange string stuff -- maybe everything is ending...
| From: | Tedd Sperling | Date: | Fri, 21 Dec 2012 21:38:48 +0000 |
| Subject: | Strange string stuff -- maybe everything is ending... | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-319922@lists.php.net to get a copy of this message | ||
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?"
_____________________
tedd@sperling.com
http://sperling.com