note 26537 added to language.types.string
| From: | vallo at rack1 dot php dot net | Date: | Sun, 03 Nov 2002 23:41:55 +0000 |
| Subject: | note 26537 added to language.types.string | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-38933@lists.php.net to get a copy of this message | ||
Even if the correct way to handle variables is determined from the context, some things just
doesn't work without doing some preparation.
I spent several hours figuring out why I couldn't index a character out of a string after doing
some math with it just before. The reason was that PHP thought the string was an integer!
$reference = $base + $userid;
.. looping commands ..
$chartohandle = $reference{$last_char - $i};
Above doesn't work. Reason: last operation with $reference is to store a product of an addition
-> integer variable. $reference .=""; (string catenation) had to be added before I got
it to work:
$reference = $base + $userid;
$reference .= "";
.. looping commands ..
$chartohandle = $reference{$last_char - $i};
Et voilá! Nice stream of single characters.
--
http://www.php.net/manual/en/language.types.string.php
http://master.php.net/manage/user-notes.php?action=edit+26537
http://master.php.net/manage/user-notes.php?action=delete+26537
http://master.php.net/manage/user-notes.php?action=reject+26537