0

我正在尝试通过我的 PHP 函数读取一个 ISP 二进制文件(以 FIPS 10-4 格式编码)。但它以不可读的格式返回数据。

    $filename = 'D:\xampp\htdocs\openx\var\jeet\GeoIPISP.dat';
    $handle = fopen($filename, "rb");
    $fsize = filesize($filename);
    $contents = fread($handle, $fsize);



   // iterate through each byte in the contents
   for($i = 0; $i < $fsize; $i++)
 { 
 // get the current ASCII character representation of the current byte
  $asciiCharacter = $contents[$i];
 // get the base 10 value of the current characer
 $base10value = ord($asciiCharacter);
 // now convert that byte from base 10 to base 2 (i.e 01001010...)
 $base2representation = base_convert($base10value, 10, 2);
 // print the 0s and 1s

 $base10value = base_convert($base2representation, 2, 10);  // => 132
 $ASCIICharacter = chr($base10value);               // => 'Z'
  echo  $ASCIICharacter; 
 }

任何人都可以如何将二进制文件的所有数据放入php字符串/数组中?

4

0 回答 0