Hướng dẫn byte array in php
How can I get the byte array from some string which can contain numbers, letters and so on? If you are familiar with Java, I am looking for the same functionality of the getBytes() method. I tried a snippet like this one:
but without success, so any kind of help will be appreciated. PS: Why do I need this at all!? Well, I need to send a byte array via fputs() to a server written in Java... dokaspar 7,65714 gold badges67 silver badges93 bronze badges asked May 19, 2009 at 23:49 @Sparr is right, but I guess you expected byte array like
By using
Be careful: the output array is of 1-based index (as it was pointed out in the comment) answered Jul 13, 2012 at 8:22 BronekBronek 10.4k2 gold badges43 silver badges45 bronze badges 2
T = 0x54, h = 0x68, ... You can split the result into two-hex-character chunks if necessary. answered May 20, 2009 at 0:29 SparrSparr 7,37730 silver badges47 bronze badges 7 PHP has no explicit answered Jul 13, 2011 at 11:48 soulmergesoulmerge 71.9k19 gold badges117 silver badges152 bronze badges 0 You could try this:
answered May 19, 2009 at 23:59 karim79karim79 336k66 gold badges410 silver badges405 bronze badges In PHP, strings are bytestreams. What exactly are you trying to do? Re: edit
answered Jun 24, 2009 at 20:30 troelskntroelskn 112k24 gold badges132 silver badges154 bronze badges 0 I found several functions defined in http://tw1.php.net/unpack are very useful. Take byteStr2byteArray() as an example:
answered Feb 13, 2014 at 5:53 1 |