PHP – Delete files by pattern

Martin Zellerphp 1 Comment

If you want to delete files by pattern (e.g. “*.txt”) in a directory, you can do this with the php function glob! [php]$files = glob(‘/path/to/files/*.txt’); // finds all txt files in the directory /path/to/files/ foreach($files as $file) unlink($file);[/php] With this method you can also delete all files of a directory – with pattern *.*

Client localisation with zend framework

Martin Zellerphp Leave a Comment

If you want to find out the language or country of the clients browser, do it this way: [php]<?php require_once ‘Zend/Locale.php’; $locale = new Zend_Locale(); echo $locale->toString(); ?>[/php] But be aware! This way you only get the localisation of the clients browser. And this is configurable by the user. The code above will give you output like this: [text]de_AT[/text] or …