if you want to "securely" remove an element of an array ....
$objects =
array('first','second','third','fourth','fifth','sixth','seventteen');
function remove_element($array, $left_id, $right_id) // Remove Element
// left_id is element position(counts from 1)
// right_id array position (counts from 0)
{
$left = array_slice ($array, 0, $left_id);
$right = array_slice ($array, $right_id);
$array = array_merge ($left, $right);
unset ($left);
unset ($right);
return $array;
}
// just give both information of the element you want to remove.
// if youi want to remove the third element transmit the array
// position (2) and the "real" position (3) to the function,
// and the element is gone ...
$objects = remove_element($objects, 2,3);
found on this page of PHP.Net
http://www.php.net/manual/en/function.array-slice.php
-----Original Message-----
From: David Tandberg-Johansen [mailto:[EMAIL PROTECTED]]
Sent: Thursday, February 15, 2001 5:05 AM
To: [EMAIL PROTECTED]
Subject: [PHP] Array
How can I delete one record in a array?
Example:
$myarray = array ("a", "b", "c");
I want to delete/take away "b" so the array is:
$myarray = array ("a", "c");
David
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]