Category Archives: PHP

Lowercase everything in string, upper case first letter in sentence

Another quick and easy one. Using ucfirst, strolower, and a few other functions. In this case my string is called $whyexp but you can change it to whatever you want just make sure you change of of them. $whyexp = ucfirst(strtolower($whyexp)); $whyexp = preg_replace_callback(‘/[.!?].*?\w/’, create_function(‘$matches’, ‘return strtoupper($matches[0]);’),$whyexp); $whyexp = str_replace(” i “,” I “, $whyexp); […]

PHP Function to return readable mysql timestamps

Something almost every PHP app needs is a way to take Mysql timestamps and convert them to a readable format. So, I went and wrote a few functions to handle this. I used PHP’s date function and strtotime to make this happen. You can edit what it returns by understanding how PHP’s date function works. […]

Lim_Registry – PHP Lazy Registry Class

Lim_Registry is a PHP Registry class met ondersteuning voor “lazy loading”. In dat geval wordt er pas een instantie van een class aangemaakt, wanneer deze uit het register wordt opgehaald. Hetzelfde geldt eventueel voor een callback functie. Hoe werkt het? // set Registry::set(‘site_title’, ‘My Site Title’); Registry::setLazyClass(‘db’, ‘DBConnection’); Registry::setLazyCallback(‘avg’, ‘getAverage’); // get $value = Registry::get(‘site_title’); // is loaded (and not in lazy state) […]