Search code examples
phpzipphp-ziparchive

How to remove id in documents before added to zip using php?


I am using ZipArchive() to zip a bunch of .txt,.pdf,.doc files together. Can someone please give me an example how to remove the ID from the beginning of all .txt,.pdf,.doc files before placing them in the zip?

for example:

144-a.txt
2-b.doc
25555-c.pdf

will be:

a.txt
b.doc
c.pdf

Solution

  • this is the example code...try this

    <?php
        $words ='3569_bcl-for-java-se-397068';
        $words1 =preg_replace('/^[0-9_]+/','',$words);
        echo $words1;
     ?>