php: read directory
2019-12-29 2019-12-30 07:26:47


here are different ways to read a directory with php.

current level

using array_diff & scandir: read /var/www/Foo/ and ignore .dot files

$aContent = array_diff(scandir ('/var/www/Foo/'), array('..', '.', '.htaccess', '.htpasswd'));

using preg_grep & scandir: read /var/www/Foo/

$aContent = preg_grep('/^([^.])/', scandir('/var/www/Foo/'));

_using 3 array* functions & scandir: read and ignore .dot files […]

php: generate a 60 char random string
2019-12-29 2019-12-29 22:02:11


Q: how to create a 60 char random string ?

A: use the benath function generateRandomString() to create such a string. Modify to your needs.


$srandomString = enerateRandomString();

it will produce a sting like:

 * @return string
function generateRandomString()
    $iLength = 30;
    $sBase = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';

This website uses Cookies to provide you with the best possible service. Please see our Privacy Policy for more information. Click the check box below to accept cookies. Then confirm with a click on "Save".