Programming Archives - Page 3 of 9 - Ian Carnaghan

Script to resize PNG, JPG and GIF images using PHP keeping the aspect ratio

How this script works: What this script does, it resizes any PNG, JPG or GIF image to the given...

Mar 22 · 1 min read >

How to remove all 0’s (zeros) from an PHP array

If I have the following PHP array $array = array(9,0,6,4,5,0,9,0,0,0); and I need to have all 0’s removed from...

Mar 22 · 10 sec read >

Getting Warning: split(): REG_BADRPT when using the split PHP function

Getting Warning: split(): REG_BADRPT when using the split PHP function when I try to split a string after each question mark...

Mar 22 · 15 sec read >

How to remove all white spaces within a string using PHP

There are two functions that could be used namely str_replace and  preg_replace. First, we’ll give an example using str_replace. str_replace is the preferred method since...

Mar 22 · 30 sec read >

How to alternate between 2 colors using PHP

This could come in handy if you have a table with multiple rows and if you wish to alternate...

Mar 22 · 27 sec read >

How to convert a MySQL Datetime field to a Unix Timestamp using PHP

In the example you’ll find a handy PHP function that will do the conversion. <?php   $DATETIME = '2010-04-22...

Mar 22 · 28 sec read >

How to get the current UNIX timestamp using PHP

UNIX TIMESTAMP: Is the time measured in seconds since the start of the Unix epoch “1 January 1970” Use the PHP...

Mar 22 · 9 sec read >

How to get the first element of an array using PHP

If you have the array $array = array('a','b','c','d'); you will need to get the value a from the array Answer: Use...

Mar 22 · 13 sec read >

How to change the Return-path email address using the PHPMailer class

Fill the $Sender property with the email address you wish to have as the Return-path  E.g. $mail->Sender="[email protected]"; This property can be found...

Mar 22 · 14 sec read >