php: read directory
2019-12-29
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 = […]
php: generate a 60 char random string
2019-12-29
Q: how to create a 60 char random string ?
A: use the benath function generateRandomString()
to create such a string. Modify to your needs.
usage
$srandomString = enerateRandomString();
it will produce a sting like:
1572437300-71425db97d34ae5da7-37619268-DSCbkJT0JoqHpPtsCiN1l
/**
* @return string
*/
function generateRandomString()
{
[…]