• <legend id='KmJJQ'><style id='KmJJQ'><dir id='KmJJQ'><q id='KmJJQ'></q></dir></style></legend>

    <tfoot id='KmJJQ'></tfoot>

    <small id='KmJJQ'></small><noframes id='KmJJQ'>

    <i id='KmJJQ'><tr id='KmJJQ'><dt id='KmJJQ'><q id='KmJJQ'><span id='KmJJQ'><b id='KmJJQ'><form id='KmJJQ'><ins id='KmJJQ'></ins><ul id='KmJJQ'></ul><sub id='KmJJQ'></sub></form><legend id='KmJJQ'></legend><bdo id='KmJJQ'><pre id='KmJJQ'><center id='KmJJQ'></center></pre></bdo></b><th id='KmJJQ'></th></span></q></dt></tr></i><div id='KmJJQ'><tfoot id='KmJJQ'></tfoot><dl id='KmJJQ'><fieldset id='KmJJQ'></fieldset></dl></div>

        • <bdo id='KmJJQ'></bdo><ul id='KmJJQ'></ul>

        PHP 将文件读取为字节数组

        时间:2023-12-01
        • <legend id='Z2UQR'><style id='Z2UQR'><dir id='Z2UQR'><q id='Z2UQR'></q></dir></style></legend>
          <i id='Z2UQR'><tr id='Z2UQR'><dt id='Z2UQR'><q id='Z2UQR'><span id='Z2UQR'><b id='Z2UQR'><form id='Z2UQR'><ins id='Z2UQR'></ins><ul id='Z2UQR'></ul><sub id='Z2UQR'></sub></form><legend id='Z2UQR'></legend><bdo id='Z2UQR'><pre id='Z2UQR'><center id='Z2UQR'></center></pre></bdo></b><th id='Z2UQR'></th></span></q></dt></tr></i><div id='Z2UQR'><tfoot id='Z2UQR'></tfoot><dl id='Z2UQR'><fieldset id='Z2UQR'></fieldset></dl></div>

              <bdo id='Z2UQR'></bdo><ul id='Z2UQR'></ul>

            • <small id='Z2UQR'></small><noframes id='Z2UQR'>

                <tfoot id='Z2UQR'></tfoot>
                  <tbody id='Z2UQR'></tbody>
                1. 本文介绍了PHP 将文件读取为字节数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个使用 JAVA 程序编写的文件,它有一个整数数组,写成二进制我在这个数组上创建了一个 for 循环并使用这个方法编写它

                  I have a file written using JAVA program which has an array of integers written as binary I made an for loop over this array and write it using this method

                  public static void writeInt(OutputStream out, int v) throws IOException {
                      out.write((v >>> 24) & 0xFF);
                      out.write((v >>> 16) & 0xFF);
                      out.write((v >>> 8) & 0xFF);
                      out.write((v >>> 0) & 0xFF);
                  }
                  

                  我问的是如何在 PHP 中读取这个文件.

                  I'm ask about how to read this file in PHP.

                  推荐答案

                  相信你要找的代码是:

                  $byteArray = unpack("N*",file_get_contents($filename));
                  

                  更新: OP 提供的工作代码

                  UPDATE: Working code supplied by OP

                  $filename = "myFile.sav"; 
                  $handle = fopen($filename, "rb"); 
                  $fsize = filesize($filename); 
                  $contents = fread($handle, $fsize); 
                  $byteArray = unpack("N*",$contents); 
                  print_r($byteArray); 
                  for($n = 0; $n < 16; $n++)
                  { 
                      echo $byteArray [$n].'<br/>'; 
                  }
                  

                  这篇关于PHP 将文件读取为字节数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:PHP中二进制的前缀是什么? 下一篇:PHP sqlsrv驱动和PDO驱动的数据类型区别

                  相关文章

                2. <small id='INUX1'></small><noframes id='INUX1'>

                  <legend id='INUX1'><style id='INUX1'><dir id='INUX1'><q id='INUX1'></q></dir></style></legend>
                    <tfoot id='INUX1'></tfoot>

                      <i id='INUX1'><tr id='INUX1'><dt id='INUX1'><q id='INUX1'><span id='INUX1'><b id='INUX1'><form id='INUX1'><ins id='INUX1'></ins><ul id='INUX1'></ul><sub id='INUX1'></sub></form><legend id='INUX1'></legend><bdo id='INUX1'><pre id='INUX1'><center id='INUX1'></center></pre></bdo></b><th id='INUX1'></th></span></q></dt></tr></i><div id='INUX1'><tfoot id='INUX1'></tfoot><dl id='INUX1'><fieldset id='INUX1'></fieldset></dl></div>
                      • <bdo id='INUX1'></bdo><ul id='INUX1'></ul>