note 29926 modified in function.array-pop by vrana
| From: | vrana@php.net | Date: | Tue, 17 Aug 2004 14:48:10 +0000 |
| Subject: | note 29926 modified in function.array-pop by vrana | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-79863@lists.php.net to get a copy of this message | ||
alex.chacon@terra.com
Hi
Here there is a function that delete a elemente from a array and re calculate indexes
<?php
function eliminarElementoArreglo ($array, $indice)
{
if (array_key_exists($indice, $array))
{
$temp = $array[0];
$array[0] = $array[$indice];
$array[$indice] = $temp;
array_shift($array);
//reacomodamos índices
for ($i = 0 ; $i < $indice ; $i++)
{
$dummy = $array[$i];
$array[$i] = $temp;
$temp = $dummy;
}
}
return $array;
}
?>
--was--
alex.chacon@terra.com
Hi
Here there is a function that delete a elemente from a array and re calculate indexes
function eliminarElementoArreglo ($array, $indice)
{
if (array_key_exists($indice, $array))
{
$temp = $array[0];
$array[0] = $array[$indice];
$array[$indice] = $temp;
array_shift($array);
//reacomodamos índices
for ($i = 0 ; $i < $indice ; $i++)
{
$dummy = $array[$i];
$array[$i] = $temp;
$temp = $dummy;
}
}
return $array;
}
http://php.net/manual/en/function.array-pop.php