Question

I have a directory that include debian packages and looks like that:

enter image description here

inside Depiction folder i have a Description for each package, each folder contains an index.php file

Inside that description page, i'm trying to find a way to get the full filename of the deb by only having the first part of the file com.name.app1 and it will automatically get the second part.

The reason i'm trying to do this, its because i will have to update the debian packages later and i don't want to edit the description page every time i update a package

And the filename i'm using it for some counter/filesize and other scripts

Thanks in advance

Was it helpful?

Solution

Using glob and regex with preg_match you can find the files:

<?php

     // define which app
    $app = "app1";

    // Search the directory for possible matches
        foreach (glob("/com.name.".$app."*") as $filename) {
            $filename . "\n";

            preg_match('/\\d\\.\\d-\\d_.*\\.deb/', $filename, $matches);
            echo "filename: com.name.".$app."_{$matches[0]}\n";
        }
?>

Result:

com.name.app1_1.0-1_iphoneos-arm.deb

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top