Copy/Paste to a php file, and observe how it works. Maybe could be usefull
for u

<?

$array1[0]="Red";
$array1[1]="Blue";
$array1[2]="White";
$array1[3]="Black";

$array2[0]="Blue";
$array2[1]="Black";

$array1_result_diff=array_diff($array1, $array2);

echo "This is an array with colors not starting with <B>\"B\"</B>";
echo "<BR>";
echo var_dump($array1_result_diff);
echo "<BR>";
echo "<BR>";
echo "<BR>";

$array2_result_diff=array_intersect($array1, $array2);
echo "This is an array with colors starting with <B>\"B\"</B>";
echo "<BR>";
echo var_dump($array2_result_diff);
?>



-----Original Message-----
From: Angelo Zanetti [mailto:[EMAIL PROTECTED]
Sent: miércoles, 01 de octubre de 2003 12:25
To: [EMAIL PROTECTED]
Subject: [PHP] removing an element from an array


Hi

If I have an array and want to remove and element from this array. correct
me if this is the wrong approach:

create a temporary array with 1 element less than the origional array, get
the position of the element ( is there a function for this?) and then run
through the origional array copying all elements besides the element which
is meant to be removed.

Is there no function to do this? It seems like alot of overhead to do this
process, especially if the array is big. comments?

Angelo

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to