It is known that the php file is UTF-8 encoded. the following content is available: $ data & nbsp ;=& nbsp; "medium"; why (int) substr ($ data, & nbsp; 0, & nbsp; 1) & nbsp ;=& nbsp; 0? How can I convert it to a correct integer? The problem of converting an integer using a subscript for a Chinese string
It is known that the php file is UTF-8 encoded, and the following content is available:
$ Data = "medium ";
Why (int) substr ($ data, 0, 1) = 0?
How can I convert it to a correct integer? PHP coding UTF-8 share:
------ Solution --------------------
Intval () or (int) since it is an ascii code, you need ord ()
------ Solution --------------------
$ Data = "medium ";
$ T = unpack ('C * ', $ data );
Print_r ($ t );
Array
(
[1] => 228.
[2] => 184.
[3] = & gt; 173
)
$data = "ABCD";
$t = unpack('C*', $data);
print_r($t);
Array
(
[1] => 65
[2] => 66
[3] => 67
[4] => 68
)