You are here: Re: atoi and similar functions? « PHP Programming Language « IT news, forums, messages
Re: atoi and similar functions?

Posted by Andy Hassall on 01/08/07 19:14

On Mon, 08 Jan 2007 09:46:16 -0800, CptDondo <yan@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.

hexdec after stripping off the leading '0x'?
http://uk.php.net/manual/en/function.hexdec.php

>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 ' '.

I think you want unpack:

<?php
$var = chr(0x20) . chr(0x21) . chr(0x22);
print join(" ", unpack('C*', $var));
?>

--
Andy Hassall :: andy@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool

 

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

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