|
Posted by K Brown on 08/18/06 17:18
Inorder to do something like
'aa' + 'bb' and get 'cc' as a result you simply need to return ascii
value of the charcters.And then increment.
in php as in every other C based language I know (C, C++, C#) the
function that does this is ord('a'). This would be implemented as follows,
Find the difference between the characters you wish to sum and add the
difference to the first character.
(ord('b') -ord('a) )+ ord('a') would yield the acii value of 'c' which
then would be converted back to a character with chr(67), again this is
pretty common to all languages.
As for your other questions, the www.php.net site has extensive
documentation on how php handles strings.
KBrown
www.gpmicro.com
The hottest Freshest Securest offsite backup on the planet.
"Dennis de Wit" <newsgroups@tomatensaus.com> wrote in message
news:44e5cada$0$4524$e4fe514c@news.xs4all.nl...
> Just figured out... $a++ has a different meaning from $a+=1 when used on a
> string. Don't ask me why anyone would use number calculations on strings,
> but why the hell does ++ behave different on this matter?
>
> Why can't i say 'aa' + 'bb' and make it turn into 'cc'? That would be the
> same logic!
>
> I 'hate' this language :S
>
> Dennis
Navigation:
[Reply to this message]
|