Skip to content
Advertisement

PHP: connect X.pdf to X.png in a chosen directory

I am looking for a PHP script that connects *.PDF to *.PNG files in a directory. Due to lack of PHP knowledge, I only know how to do this manually in HTML. Could PHP do this for me automatically by connecting A.pdf with A.png, B.pdf with B.png, C.pdf with C.png and so on? Then all I need to be able doing is to change the folder name in PHP.

JavaScript

etcetera…

Advertisement

Answer

I’m not sure if I understood this correctly, but the code below will get all .pdf files from a directory and return the HTML for each .pdf file. This will also check to see if the .png exists, but will not echo anything if it does not exist.

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement