You are here: Re: I hate this language :-D « All PHP « IT news, forums, messages
Re: I hate this language :-D

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация