FREE PHP source code and scripts

PHP function to return a file's suffix

function return_suffix($filename){
    return substr($filename,strrpos($filename,".")+1);

PHP function to strip a file's suffix and return the filename without it's suffix (assuming the suffix is 3 characters long)

function strip_suffix($filename){
    return substr($filename,0,-4);

PHP function to convert a number of months into years and months

function format_months_to_years_and_months($months){
    if ($y>1){$t.="$y years ";}else if ($y>0){$t.="$y year ";}
    if ($m>1){$t.="$m months ";}else if ($m>0){$t.="$m month ";}
    return $t;

PHP function to remove numbers from a string

function remove_numbers($string) {
     return $string;

If you find any of our free PHP source code useful we would love to hear from you and would be happy to add more if we know someone can benefit from it.

A selection of FREE PHP functions, scripts and source code
Tags: php, php developers, php programming, php web development