about 1 month ago - No comments
If, like me, you need to access some Zend_Application resources (such as multidb resources) – then you need a reference to the Zend_Application and the bootstrap. I use this: if (null == $this->_application) { $this->_application = Zend_Controller_Front::getInstance() ->getParam(‘bootstrap’); }
about 2 months ago - No comments
ThisĀ horrendousĀ regular expression will parse a string and return a valid email address from it. $email = “<’Freddy’> fred@live.com”; preg_match(‘/[a-z0-9!#$%&\'*+\/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&\'*+\/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?/’, $email, $match); echo $match[0]; This will return: fred@live.com Basically, if you pass an array as the third parameter of the preg_match method, it will be filled with the preg_match results, and the first item of the
about 4 months ago - No comments
When backing up a source code working copy, you don’t always want all the little .svn folders everywhere. You can “export” the working copy, or if you forgot, you have remove them all. Change the the folder containing the working copy (this is very important*) cd /home/username/www/sitename/ And then remove them all, recursively with this
about 5 months ago - 6 comments
Say you have a list of movie titles, and you want to either sort them, or search through them, and some of them have “The ” at the start, for example: The Simpsons Simpson Street When doing a MySQL search: SELECT * FROM movies WHERE title LIKE “The Simp%”; Would only return the first row.
about 5 months ago - No comments
Removing letters from a string using Regular Expressions. Very simple. but brain bending – All I wanted to do was remove a prefix from a string. The prefix was always letters, and I only wanted the numerical suffix returned, so though, preg_replace was my best bet. echo preg_replace(“/[a-zA-Z]*/”, ”, ’12345MystrING67890′); This returns : 1234567890 Perfect.
about 5 months ago - No comments
Regular expressions — everyone loves them, right? Well, I am currently running Ubuntu, and I would normally use RegexBuddy – but cannot unless I use Wine, and I don’t really like to. So, I wanted to find an online solution for my needs. So, I found this one, that allows my to test my regular