Re: preg_grep bug?!?

From: Date: Mon, 19 Mar 2001 15:29:31 +0000
Subject: Re: preg_grep bug?!?
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-49351@lists.php.net to get a copy of this message
On Mon, 19 Mar 2001, William N. Zanatta wrote: > Hello ppl, > > I have a dropdown menu which lists some countries. These countries are > also in a database and each of them have an ID number used for control. > Well, when I insert an entry for each of the countries in the database, > the next time I click on the dropdown this country must not appear > again. For this, I use preg_grep($country, $country_list) where > $country is the current country code and $country_list is the array of > already known country codes. > The problem is(I'm gonna show it by the country codes): I have > 1, 2, 3, 4...12 countries > Then I insert firstly the 12th. When the script executes the preg_grep > next time I'll get 3, 4...11. Well, it kicked away my 1 and 2 just > because of 12. > Is this a normal behavior??? > Sorry for the dazed text and thanx, Since 4.0.4, preg_grep() returns the entries under keys from the original array. You might want to try doing array_values() on the results of preg_grep() to avoid that. -Andrei * On the keyboard of life, always keep one finger on the escape key. *

« previous php.dev (#49351) next »