On Mon, 13 Nov 2006 14:13:12 +0100, Martin <maa@scandesigns.dk> wrote:
>Hvis man har et array ala
>Array[0] = "foo"
>Array[1] = "bar"
>Array[2] = "baz"
>Array[3] = "foo2"
>Array[4] = "bar2"
>Array[5] = "baz2"
>Array[6] = "foo3"
>Array[7] = "bar3"
>Array[8] = "baz3"
>
>man gerne vil fjerne Array[5] også skal resten af arrayet så
>"nulstilles" så Array[6] så bliver til [5] og Array[7] bliver [6] osv.
>
>Hvad er det den funktion hedder? - Kan bare ikke lige finde den
Du kan bruge array_splice.
<?
$array[0] = "foo1";
$array[1] = "foo2";
$array[2] = "foo3";
$array[3] = "foo4";
$array[4] = "foo5";
$array[5] = "foo6";
$array[6] = "foo7";
$array[7] = "foo8";
$array[8] = "foo9";
print "<b>Start:</b><br>";
print "<pre>";
print_r($array);
print "</pre>";
print "<br><br>";
$elements_removed = array_splice($array,4,1);
print "<b>Efter splice:</b><br>";
print "<pre>";
print_r($array);
print "</pre>";
print "<br><br>";
?>
--
Med venlig hilsen,
Martin Mouritzen.
http://www.siteloom.dk