[PHP] Once more: [PHP] Array indices - PLEASE HELP!!
Does nobody have a suggestion to the below? Perhaps there is an easy solution, but I cant see it at the time. Eivind Hi all, I have a question regarding array indices: At a certain point in code, I run array_diff() on two arrays to produce a reduced version of one of the argument arrays. Problem is, I dont want the key-value associations to be preserved. I need that the returned array has new (integer, not string) indices in numerical order from 0...N without holes. Does anybody know how to do this? I have looked at different sort functions etc, but I'd rather not do a sort to the array. The code is for random selection with reduction of the sample set (i.e. with withdrawal). -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Once more: [PHP] Array indices - PLEASE HELP!!
On Wednesday 24 April 2002 17:14, esivertsen wrote: Does nobody have a suggestion to the below? Perhaps there is an easy solution, but I cant see it at the time. Eivind Hi all, I have a question regarding array indices: At a certain point in code, I run array_diff() on two arrays to produce a reduced version of one of the argument arrays. Problem is, I dont want the key-value associations to be preserved. I need that the returned array has new (integer, not string) indices in numerical order from 0...N without holes. Does anybody know how to do this? I have looked at different sort functions etc, but I'd rather not do a sort to the array. The code is for random selection with reduction of the sample set (i.e. with withdrawal). just run your array through a foreach loop assigning each key-value pair to a new array. -- Jason Wong - Gremlins Associates - www.gremlins.com.hk Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * /* Be not anxious about what you have, but about what you are. -- Pope St. Gregory I */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Once more: [PHP] Array indices - PLEASE HELP!!
just run your array through a foreach loop assigning each key-value pair to a new array. OK, I was trying to see if there was a more elegant way to do it, so I wouldn't have to make the loop. Like just re-mapping the indices to default values by a short and simple operation. But it will do the work! Thanks a lot for your suggestion, Eivind :-) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Array indices
Hi all, I have a question regarding array indices: At a certain point in code, I run array_diff() on two arrays to produce a reduced version of one of the argument arrays. Problem is, I dont want the key-value associations to be preserved. I need that the returned array has new (integer, not string) indices in numerical order from 0...N without holes. Does anybody know how to do this? I have looked at different sort functions etc, but I'd rather not do a sort to the array. The code is for random selection with reduction of the sample set (i.e. with withdrawal). All the best, Eivind -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php