Return to Snippet

Revision: 13094
at April 8, 2009 09:40 by braunsHizzzle


Initial Code
function instrrev($n,$s) {
	$x=strpos(chr(0).strrev($n),$s)+0;
	return (($x==0) ? 0 : strlen($n)-$x+1);
 }
  
function mid($s,$x,$w="") {  //$w is optional
	if ($w) {return substr($s,$x-1,$w);}
    else {return substr($s,$x-1);}
}

function deleteLastComma($valStr) {
	$lastCommaPos = instrrev($valStr, ",");
	$valStr = mid($valStr, 1, $lastCommaPos - 1);
	return  $valStr;
}

Initial URL
http://www.totaldream.org

Initial Description
This is the PHP equivalent to http://snipplr.com/view/12074/delete-last-comma/

You will use only the deleteLastComma() function!

Initial Title
Delete Last Comma in a string

Initial Tags

                                

Initial Language
PHP