It is known that the php file is UTF-8 encoded. the following content is available: $ data & nbsp; medium; why (int) substr ($ data, & nbsp; 0, & nbsp; 1) & nbsp; 0? How can I convert it to a correct integer? How to convert an integer from a subscript to a Chinese character string in PHP
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
)