Reading a File into a Byte Array (PHP)

前端 未结 4 1739
無奈伤痛
無奈伤痛 2020-12-11 05:42

I have one file. but now need to read this file into a bytes array. In java or c++ it\'s very easy to do that. but not found how i can read in PHP.

4条回答
  •  南方客
    南方客 (楼主)
    2020-12-11 06:20

    too much php>

    $data = file_get_contents("/tmp/some_file.txt");

    best way to make for (not recomended in for use count, sizeof, strlen or other functions): $counter = strlen($data); for($i = 0; $i < $counter; ++$i) { $char = data[$i]; echo "Byte $i: $char\n"; }

提交回复
热议问题