0, 1, 1, 2, 3, 5, 8, 13, 21... seem familiar? It's the Fibonacci sequence! The Fibonacci sequence is calculated by adding the last two numbers together to get the next number in the series. This simple PHP program helps you calculate numbers in the Fibonacci sequence.
One of the types of loops in PHP is a while loop. This loop will continue to repeat as long as (while) a certain condition is true. Once the condition becomes false, the loop will end. [read more]
There is a function in PHP that you can use to generate unique IDs. It is the Uniqid () function. You can choose to add a prefix to what is generated as well. [read more]
I was recently asked on Twitter how a person would calculate a week before Easter. It's actually very simple, you just have to do a little bit of timestamp math, and date formatting. Read how to do it here.
You can generate a time stamp in PHP using time (). This will return a number that represents the amount of seconds that have passed since January 1, 1970 at midnight GMT. You can then format this number in different ways for your needs. [read more]
In PHP you can find the tangent of an angle using the tan () function. It expects your input to be in radians. For example tan (M_PI_2). [read more]
In PHP you can use a switch loop to help a computer decided between several different choices. A switch loop uses the switch () function, and can have as many cases as you need. [read more]
You can use the str_replace () PHP function to search and replace within a string. Here is an example of how you would use it to strip out vowels:
$vowels = array("a", "e", "i", "o", "u"); $no = str_replace($vowels, "", "My name is Joe Smith"); Print $no;
Do you have a job interview coming up for a technical position, as a PHP programmer? Or are you interested in having one in the future? Have a look at these technical interview tips.
Copyleft software is a form of open source software that requires all future deviations of the work be released under the same license. So, if you release it for free you can ensure that all future versions of it are also free. Read More.