Arrays

From: Date: Sun, 13 Aug 2000 15:36:59 +0000
Subject: Arrays
Groups: php.general 
Request: Send a blank email to php-general+get-16587@lists.php.net to get a copy of this message
This may sound trivial, but its causing me a headache right now. When I first looked around in php and its similarities to c++ I noticed there are no std container classes (you know, like the standard template library). Specifically what I am looking for is the list data structure. The array seems to do most of the things the list does, such as poping and pushing and such. But why is there no way to delete an item from the middle of an array? I forgot the algorithm I used in c++ and that's what's causing me the headache. I know I can simply create a second array and copy only the values I want to keep into the temp array, and then after zeroing out the first array, copy the values back into it. However, that's kinda costly since I already have the worlds most "for" statements in a page :) So 2 questions: 1. Does anybody have a good algorithm for deleting a single item out of an array? 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? Thanks.

« previous php.general (#16587) next »