ListDeleteAt

The ListDeleteAt function is a neat little coldfusion function and works just as well in PHP. This function is good for removing counted values from lists. I use it a lot in conjunction with other list functions.
The Function:

<php
function ListDeleteAt($list,$position,$delimiter)
{
$delimiter = substr($delimiter, 1);
$a = explode($delimiter,$list);
for($i=0;$i<count($a);$i++)

{
if($i != $position)
{
if(! isset($return))
{
$return = $a[$i];
}
else
{
$return .= $delimiter . $a[$i];
}
}
}
return $return;
}
?>

Usage:

To use the ListDeleteAt function with the default delimiter ',':

<php
$list = "a,b,c,d,e,f,g";

$position = 3;
echo ListDeleteAt($list,$position);
?>
The Result: a,b,d,e,f,g. The 'c' which was in the third position has noe been removed!

To use the ListDeleteAt function with a custom delimiter:

<php
$list = "12345";

$position = 2;
echo ListDeleteAt($list,$position);
?>

The Result: '1345'. The '2' which was in the second position has noe been removed!