Create daterange array of missing dates

[code lang=”php”] //fromDate 2014-01-22 //toDate 2014-02-20 //$arr Array ( [0] => Array ( [ISO_DATE] => 2014-02-18 [DAY_SUM_AMOUNT] => 3000 [DAY_SUM_VOLUME] => 2 [CONVERSION_PCT] => 100 ) [1] => Array ( [ISO_DATE] => 2014-02-19 [DAY_SUM_AMOUNT] => 4000 [DAY_SUM_VOLUME] => 1 [CONVERSION_PCT] => 100 ) ) //codetime function createDateRangeArray($strDateFrom,$strDateTo) { $aryRange=array(); $iDateFrom=mktime(1,0,0,substr($strDateFrom,5,2), Read more…

By Andrew Odendaal, ago

URL GET vars to PHP Array

Sometimes you will need to retrieve the GET variables passed into the current page URI or you will have a URL string to work from which contains certain GET variables, the below method helps a lot to convert them into an array which you can easily manipulate later. [code lang=”php”] Read more…

By Andrew Odendaal, ago

Remove specific HTML tags using PHP

There are times when you want to remove a specific HTML tag from an HTML block of text. This could be an anchor(<a/>>) or an image(<img/>) perhaps. You can use preg_replace to do this quite quickly and efficiently. Remove an anchor: [code lang=”php”] $content = “Sample text Our anchor. Etc Read more…

By Andrew Odendaal, ago

Let Joomla and MySQL interact!

I often need a quick and easy few lines to retrieve some data from MySQL using Joomla without all the MVC nonsense that usually goes about this topic. So here is how I do it! [code lang=”php”] $dbSEL = JFactory::getDbo(); $dbSEL->setQuery(“SELECT MAX(`start_price`) FROM #__some_table”); $dbSEL->query(); echo $dbSEL->fetchRow(); [/code] As you Read more…

By Andrew Odendaal, ago

Perform a Mysql Query using Joomla!

This is really actually meant for future reference for myself as lately I’ve been doing quite a lot of Joomla! mysql coding and have used the following code just short of 3million times. $db = JFactory::getDbo(); $querySelectId = "SELECT `id` FROM #__some_table WHERE `user_id`='$user_id'"; $db->setQuery($querySelectId); $db->query(); $data = $db->loadAssoc(); What Read more…

By Andrew Odendaal, ago

Refresh User Data in Joomla

I was busy with a custom component in Joomla, and it stored it’s own user_details based off of the main users table, but if the details were changed then I needed the system to update the session to reflect the changes. This is what I did: $user = JFactory::getUser(); $session Read more…

By Andrew Odendaal, ago

Extract email addresses from a string – PHP

Sometimes you need to extract multiple email addresses from a string and the following function will make all your dreams come true. [code lang=”php”] function extract_emails_from($string){ preg_match_all(“/[\._a-zA-Z0-9-][email protected][\._a-zA-Z0-9-]+/i”, $string, $matches); return $matches[0]; } [/code] ..and this is how you use it: [code lang=”php”] $text = “this is some text and here Read more…

By Andrew Odendaal, ago

Pad a string with zeros using PHP

Recently I had to create a code/username maker to fit into a certain type of pattern so that all “broker codes” (as they were called) followed the same path. An example one looked like so: [code lang=”bash”] HJTH0001 [/code] The number needed to increment and I wanted to use the Read more…

By Andrew Odendaal, ago