Home >Backend Development >PHP Tutorial >php怎么按照字节 读取input

php怎么按照字节 读取input

WBOY
WBOYOriginal
2016-06-13 10:13:52784browse

php如何按照字节 读取input

因为别人post过来的数据 
前4个字节是 个数字

4个字节以后是 字符串

再后面4个字节又是别的请问 
咋么读取啊?

------解决方案--------------------
如果按你说的是每段定长的话(4个字节)
$ar = str_split($_POST['变量名'], 4);

如果是每段不定长的
比如 1,2,3,4,5

$mask = array(1,2,3,4,5);
$s = $_POST['变量名'];
$n = 0;
for($i=0; $i $ar[] = substr($s, $n, $mask[$i]);
$n += $mask[$i];
}



------解决方案--------------------
$_POST['id'][0]
$_POST['id'][1]
$_POST['id'][2]
$_POST['id'][3]

你循环遍历就可以了。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn