Re: Arrays
| From: | Robin Vickery | Date: | Wed, 13 Sep 2000 16:11:58 +0000 |
| Subject: | Re: Arrays | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-16596@lists.php.net to get a copy of this message | ||
dime@gulfsales.com ("Glover George") writes:
> So 2 questions:
>
> 1. Does anybody have a good algorithm for deleting a single item out of an
> array?
$i = 4;
$array = array( 0,1,2,3,4,5,6,7,8,9 );
$array = array_merge(array_slice($array,0,$i), array_slice($array,$i+1));
Deletes the 4th element from $array (I assume if you're thinking of using
array_values that you're using php4).
> 2. If I am going to use my method, once I have filled my temporary array
> with the wanted values, will somthing like the following work?
>
> $original_array = array_values($temp_array);
>
> or will I have to zero the original array out first?
$original_array = $temp_array;
Would work just as well, if that's really what you want to do.
-robin
--
Robin Vickery...............................................
Planet-Three, 3A West Point, Warple Way, London, W3 0RG, UK
Email: robin@planet-three.net Phone: +44 (0)870 729 5444