note 41120 deleted from function.array-pop by crell
| From: | crell@php.net | Date: | Tue, 12 Apr 2022 01:08:07 +0000 |
| Subject: | note 41120 deleted from function.array-pop by crell | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-218204@lists.php.net to get a copy of this message | ||
Note Submitter:
----
A function to delete an array value that recalculates the index ( its very short and easy to
understand ).
Hope this might help someone...
<?php
/* Usage:
$array : Array
$indey : Integer
The value of $array at the index $index will be
deleted by the function.
*/
function array_trim ( $array, $index ) {
if ( is_array ( $array ) ) {
unset ( $array[$index] );
array_unshift ( $array, array_shift ( $array ) );
return $array;
}
else {
return false;
}
}
?>