Reply to Re: atoi and similar functions?

Your name:

Reply:


Posted by Curtis on 01/09/07 10:47

PHP is a loosely and dynamically typed language, so there's no need to
explicitly convert from string to integer, in most cases.

If you want to convert from hex to decimal, check out the hexdec
function. See: http://php.net/hexdec

To convert a binary string to an integer, you can use bindec(): See
http://php.net/bindec

$dec = intval(bindec($binaryString));


Curtis

On Jan 8, 9:46 am, CptDondo <y...@NsOeSiPnAeMr.com> wrote:
> Could someone please let me know the equivalent of C atoi and similar
> functions? I need to convert a hex text string - e.g. '0x01' - to its
> integer equivalent.
>
> I also want to be able to print the contents of a binary string as its
> integer values:
>
> $x = pack("n",0x20);
> print $x;
>
> prints one space, as 0x20 is the ascii representation for a ' '.
>
> My C background really blinds me sometimes....
>
> --Yan

[Back to original 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

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