php怎么按照字节 读取input

WBOY
Release: 2016-06-13 13:37:56
Original
863 people have browsed it

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]

你循环遍历就可以了。

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!