PHP Archives - Page 2 of 6 - Ian Carnaghan

How to remove values in one array from another array using PHP

Example: I have array A with values and another array B. I need to remove the values in array A from the values in...

Mar 22 · 30 sec read >

How to check which version of PHP you are running on Linux

NOTE: Tested on Centos 4 & 5 and Ubuntu 9.04 In the command line type in the following command...

Mar 22 · 9 sec read >

How to display code as content using PHP as your programming language

I have the following JavaScript code that I need to display as plain content on a page and when I add...

Mar 22 · 26 sec read >

How to remove the first element of an array using PHP and then storing the element in a variable

By using the PHP function ‘array_shift‘ we can remove the first value of an array array_shift – Shift an element off...

Mar 22 · 29 sec read >

How to force a CSV file to download when clicking on a download link using PHP

Example: We have a CSV file called example.csv we want users to download to use as a template. Now some browsers will display the contents of the...

Mar 22 · 42 sec read >

How to convert all $_POST or $_GET values to Integers

By using the built-in PHP functions  array_map and intval. array_map = Applies the callback to the elements of the given arrays, this applies...

Mar 22 · 16 sec read >

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 >