PHP Code UTF-8
The php file is known to be UTF8 encoded and is available as follows:
$data = "Medium";
Why (int) substr ($data, 0, 1) = = 0?
How can I convert to the correct integer?
Reply to discussion (solution)
Emergency, urgent and urgent
This post was last edited by xuzuning on 2013-07-23 18:25:20
$data = "Medium";
Echo Ord (substr ($data, 0, 1)); 228
Only the first digit character in a string can be converted directly to a numeric value
Echo ' 0123ABC ' +0; 123
echo (int) ' 0123ABC '; 123
How can I convert substr ($data, 0, 1) into numbers?
I don't understand what LZ is trying to do.
Take the ASCII code and then go int?
Reference function is not used, is the meaning of upstairs
Intval () or (int) since it is an ASCII code, you need Ord ()
Intval () or (int) since it is an ASCII code, you need Ord ()
I want to loop through the ASCII values for each character in the string.
I shorted out, I can take a single character of a string, and then call Ord () for each character
There's still something wrong with the feeling.
$data = "Medium"; $t = Unpack (' c* ', $data);p Rint_r ($t);
Array
(
[1] = 228
[2] = 184
[3] = 173
)
$data = "ABCD"; $t = Unpack (' c* ', $data);p Rint_r ($t);
Array
(
[1] = 65
[2] = 66
[3] = 67
[4] = 68
)
This should be done upstairs.