Reply to pack format - how do I handle int->char conversion?

Your name:

Reply:


Posted by CptDondo on 12/08/06 21:27

I am trying to pack a string. The data consists of an array of
integers, something like this:

e[1] 0x1234
e[2] 0x0001
e[3] 0x0002

What I want in my resulting packed $binrow is

0x1234 0x01 0x02

I've tried

pack("nCC",e[1],e[2],e[3])

but that packs it like this:

0x1234 0x00 0x31 0x00 0x32

which is most definitely not what I want.

How can I explicitly tell PHP that I want to cast an int as a char?

(Sorry if this is a FAQ somewhere, but I can't find it... This is
trivial to my C-trained mind but I can't see how to do it in PHP.)

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

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