I am very new to PHP
I want to create a byte array something like this (in Java):
byte array[] = { (byte) 0x9C, (byte) 0xA0};
How do I do it in PHP? Any syntactical help highly apreciated.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
What exactly do you mean by “hexadecimal to byte”?
I am going to assume you mean “… to decimal”.
The result of
0x3fwhen output will be automatically converted to a decimal number. In internal calculations, it will be converted automatically if needed – you can dowithout problems.
You can cast a variable to an integer using
(int)$varnameor(int)valuebut it doesn’t really make sense in your case. A byte is a byte, whether you express its value as0x3For63.To convert hexadecimal to decimal, there is also
hexdec()