Use following function to convert time into different units e.g. days, months, years, weeks etc It take the value in seconds.
Continue reading...12 October 2011
This simple function returns a shorten string back.
Continue reading...12 October 2011
A very useful function that can be used to calculate distance between two points using latitude and longitude values. $unit parameter can be passed to get return in miles, kilometers, or nautical miles. How to use: Another function:
Continue reading...7 September 2011
Following PHP script uses CURL to login into a Joomla 1.5 website to access private pages.
Continue reading...5 September 2011
PHP comes with a ZipArchive class that lets us create and manipulate .zip files. Creating a Zip file using PHP Following code will create master.zip with files containing master.css, new.css, layout.css Extracting a Zip file using PHP
Continue reading...4 September 2011
On my Ubuntu 4.9 with PHP Version 5.3.2-1 I had to install Magento that required myscrypt. To install it, I followed following steps: Sometimes you might get the message “php5-mcrypt is already the newest version“. If so, install with:
Continue reading...26 August 2011
While developing a twitter extension I came across following warning message on my Ubuntu development server. After doing some research I found that curl follow location option tells curl to follow a redirect header or not. If the environment in the php.ini is running php in safe mode or an open base dir is set, [...]
Continue reading...2 March 2011
Following function will generate id’s/keys without using MD5 or SHA1. PHP function uniqid() to generate Unique ID’s. It will create prefixed unique identifier based on current time in microseconds. This function will return (13 + prefix length) characters long identifier. If ‘lcg’ is true then it will return (prefix length + 23) characters. This function [...]
Continue reading...2 March 2011
How to create a function that accepts any number of arguments? We can use func_get_args. It returns an array comprising a function’s argument list. // note empty argument list function foo() { // func_get_args will return an array of all passed arguments $args = func_get_args(); // Now we can loop through array and find arguments [...]
Continue reading...21 September 2010
Following are various functions to find domain name in URL using PHP. Regex Method:
Continue reading...
12 October 2011
0 Comments