It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened,
visit the help center.
Closed 7 years ago.
I was wondering how one would get the Text representation of a series of bytes in PHP? (Basically, the PHP version of C#'s Encoding.getString(string s)
method.)
I've been scouring google, and I can find how to get a textstring-to-bytes, but not the other way around.
In PHP such a method:
Encoding.GetString Method (Byte[])
is not necessary because in PHP, strings are like Byte[]. And that's it. So there is no such method, however you can easily write it yourself:
function Encoding_GetString($stringOfBytes) {
return (string) $byteString;
}
If you want to convert an array of integers in the range of 0-255 into a string, you can use chr
, array_map
and implode
:
$string = implode(array_map('chr', $arrayOfByteIntegers));