日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
php怎么實(shí)現(xiàn)轉(zhuǎn)成byte數(shù)組

本文操作環(huán)境:Windows7系統(tǒng)、php7.1版、DELL G3電腦

為企業(yè)提供成都做網(wǎng)站、成都網(wǎng)站建設(shè)、網(wǎng)站優(yōu)化、營銷型網(wǎng)站建設(shè)、競價托管、品牌運(yùn)營等營銷獲客服務(wù)。創(chuàng)新互聯(lián)公司擁有網(wǎng)絡(luò)營銷運(yùn)營團(tuán)隊(duì),以豐富的互聯(lián)網(wǎng)營銷經(jīng)驗(yàn)助力企業(yè)精準(zhǔn)獲客,真正落地解決中小企業(yè)營銷獲客難題,做到“讓獲客更簡單”。自創(chuàng)立至今,成功用技術(shù)實(shí)力解決了企業(yè)“網(wǎng)站建設(shè)、網(wǎng)絡(luò)品牌塑造、網(wǎng)絡(luò)營銷”三大難題,同時降低了營銷成本,提高了有效客戶轉(zhuǎn)化率,獲得了眾多企業(yè)客戶的高度認(rèn)可!

php怎么實(shí)現(xiàn)轉(zhuǎn)成byte數(shù)組?

php轉(zhuǎn)換byte[]數(shù)據(jù)類型

代碼如下:

= 128){
                $byte = ord($str[$i]) - 256;
            }else{
                $byte = ord($str[$i]);
            }
            $bytes[] =  $byte ;
        }
        return $bytes;
    }
 
    /**
     * 將字節(jié)數(shù)組轉(zhuǎn)化為string類型的數(shù)據(jù)
     * @param $bytes 字節(jié)數(shù)組
     * @param $str 目標(biāo)字符串
     * @return 一個string類型的數(shù)據(jù)
     */
    public static function tostr($bytes) {
        $str = '';
        foreach($bytes as $ch) {
            $str .= chr($ch);
        }
        return $str;
    }
 
    /**
     * 轉(zhuǎn)換一個int為byte數(shù)組
     * @param $byt 目標(biāo)byte數(shù)組
     * @param $val 需要轉(zhuǎn)換的字符串
     */
    public static function integertobytes($val) {
        $byt = array();
        $byt[0] = ($val & 0xff);
        $byt[1] = ($val >> 8 & 0xff);
        $byt[2] = ($val >> 16 & 0xff);
        $byt[3] = ($val >> 24 & 0xff);
        return $byt;
    }
 
    /**
     * 從字節(jié)數(shù)組中指定的位置讀取一個integer類型的數(shù)據(jù)
     * @param $bytes 字節(jié)數(shù)組
     * @param $position 指定的開始位置
     * @return 一個integer類型的數(shù)據(jù)
     */
    public static function bytestointeger($bytes, $position) {
        $val = 0;
        $val = $bytes[$position + 3] & 0xff;
        $val <<= 8;
        $val |= $bytes[$position + 2] & 0xff;
        $val <<= 8;
        $val |= $bytes[$position + 1] & 0xff;
        $val <<= 8;
        $val |= $bytes[$position] & 0xff;
        return $val;
    }
 
    /**
     * 轉(zhuǎn)換一個shor字符串為byte數(shù)組
     * @param $byt 目標(biāo)byte數(shù)組
     * @param $val 需要轉(zhuǎn)換的字符串
     */
    public static function shorttobytes($val) {
        $byt = array();
        $byt[0] = ($val & 0xff);
        $byt[1] = ($val >> 8 & 0xff);
        return $byt;
    }
 
    /**
     * 從字節(jié)數(shù)組中指定的位置讀取一個short類型的數(shù)據(jù)。
     * @param $bytes 字節(jié)數(shù)組
     * @param $position 指定的開始位置
     * @return 一個short類型的數(shù)據(jù)
     */
    public static function bytestoshort($bytes, $position) {
        $val = 0;
        $val = $bytes[$position + 1] & 0xff;
        $val = $val << 8;
        $val |= $bytes[$position] & 0xff;
        return $val;
    }
}

新聞名稱:php怎么實(shí)現(xiàn)轉(zhuǎn)成byte數(shù)組
分享鏈接:http://www.5511xx.com/article/dhgscjg.html