12345678910111213141516171819202122232425262728293031323334 |
- <?php
- namespace app\common\plugin;
- /**
- * byte数组与字符串转化类
- * @author ZT
- */
- class Varbinary {
-
- public static function byteArrayTofloatArray($bb)
- {
- $f=array();
- for ($i = 0; $i < strlen($bb); $i = $i + 4)
- {
- array_push($f,sprintf("%.5f",array_values(unpack('f',$bb[$i].$bb[$i + 1].$bb[$i + 2].$bb[$i + 3] ))[0]));
- }
- return $f;
- }
-
- public static function byteArrayTodatetimeArray($bb)
- {
- $t=array();
- for ($i = 0; $i < strlen($bb); $i = $i + 8)
- {
- array_push($t,self::dealValue(array_values(unpack('Q',$bb[$i].$bb[$i + 1].$bb[$i + 2].$bb[$i + 3].$bb[$i + 4].$bb[$i + 5].$bb[$i + 6].$bb[$i + 7]))[0]));
- }
- return $t;
- }
-
- public static function dealValue($date){
- return date('Y-m-d H:i:s',($date - 621355968000000000) / 10000000-8*3600);
- }
-
- }
|