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.
You can read the file into a string like this:
$data = file_get_contents("/tmp/some_file.txt");
You can get at the individual bytes similar to how you would in C:
for($i = 0; $i < strlen($data); ++$i) { $char = $data[$i]; echo "Byte $i: $char "; }
References:
1.4m articles
1.4m replys
5 comments
57.0k users