<?php
$code=array(
"username"=>array("A20"),
"pass"=>array("A10"),
"age"=>array("C"),
"birthday"=>array("I"),
"email"=>array("A50"));
$stream=file_get_contents("c:/1.txt");
var_dump(packByArr($stream,$code));
function packByArr($str,$code) {
$Arr=explode("\0",$str);
$atArr=array();
$i=0;
foreach ($code as $k=>$v) {
$atArr[$k]=unpack($v[0],$Arr[$i]);
$i++;
}
return $atArr;
}
?>
您可能感兴趣的文章: