pdf to byte array conversion in php

37
February 12, 2019, at 5:10 PM

I need to convert Pdf file to byte array conversion in php. I am looking for like this result.

This result have byte conversation of Pdf file.

What id did:

$file = file_get_contents("pdf.pdf");
$fileData = base64_encode($file);
echo $fileData;

It does not works for me. how to convert PDf file to byte array?

Answer 1

This will get you the whole file into a string:

$fileContents = file_get_contents($file);

If you want an array of one-character strings, you can do this:

$byteArray = str_split($fileContents);

If you want an array of integer ASCII values, you can do this:

$byteArray = unpack('C*', $fileContents);
READ ALSO
Need help getting index or identifier to use it as an unique key from JSON object without converting it to an array

Need help getting index or identifier to use it as an unique key from JSON object without converting it to an array

i'm provided with a JSON object and i can output the values as i want to, but i also want to use the numbers (83 & 167 generated randomly) as shown in the code as an unique identifier, but i can't seem to get only the numbers, can someone point me in the right direction?

37
facebook chatbot send last news automatically

facebook chatbot send last news automatically

i make facebook chatbot with PHP but i want to send to all subscribe users the last news automatically every day (programming by specific time)

19
Hiding Stream Key from Source View and Web Console

Hiding Stream Key from Source View and Web Console

I have a live streaming site I'm currently working on and am running into an issue hiding the stream key fullyI've only thought of one option to get around this, but you're still able to see the stream key in view source and web console output:

27
array_keys returns in addition to correct results wrong results

array_keys returns in addition to correct results wrong results

(question edited) I been struggeling with this script for while and cant get it to work right

30