First bit of new functionality work i’ve done in ModX for a longtime and I came unstuck by not being able to create any new template variables, due the the fact that ModX thought I had invalid characters in the variable title. Continue reading “ModX: Invalid Characters in a TV Name”
Getting File Extension Using PHP
Quick post, more as a reference for myself, of how to get the extension of a file using PHP.
Discovered a great post on Cowburn.info outlining the various ways to do this and the time implications, ending up with:
$filename = 'mypic.gif';
$ext = pathinfo($filename, PATHINFO_EXTENSION);
being the best option. Continue reading “Getting File Extension Using PHP”
Using RegEx To Determine If Search Query Is A Postcode/Partial Postcode
Working on a site which asks users to enter a “place name, area or postcode” to search by, niggly problem where searching for postcode “OX2” for example, not only returned properties in OX2, but also in OX29. Continue reading “Using RegEx To Determine If Search Query Is A Postcode/Partial Postcode”
Replacing accented character with it’s standard character in PHP
When writing a function to save audio files with a user friendly filename , as well as a regex to remove any unwanted spaces and punctuation, I needed to replace any accented characters with their standard format.
e.g If I was saving a Beyoncé album I needed the ‘é’ in her name to be replaced with an ‘e’.
The following works perfectly:
iconv("utf-8","ascii//TRANSLIT",$filename);