I'm reading from a file through 'file_get_contents'. After exploding the content, one of the elements is presented this way when I dump it:
dd($myVariable);
b"Crédito"
I've read on the internet that this is some kind of 'binary' string, related to a PHP version 6 that never existed. But I simply can not find a way to convert it to a 'regular' string.
I thought they were somehow equivalent, but I can't even use it to compare to another string. For example, none of these will ever return true:
if ($myVariable == "Crédito")
if ($myVariable === "Crédito")
if ($myVariable == b"Crédito")
if ($myVariable == (binary)"Crédito")
How can I convert it to a regular string?
You would need to unpack the binary data into a readable string using the unpack
function (http://php.net/manual/en/function.unpack.php)
Example for a string:
$var = b"binary";
$unpacked = unpack("a*", $var); // "a*" stands for as much as NUL-padded strings as possible
var_dump($unpacked);