Page 1 of 1

Validate and retrieve info Multidimension array

Posted: Thu Mar 10, 2011 9:10 pm
by trailrunner1
I have an array
haystack[0] array (
email => 'xyz@hotmail.com'
phone => '333-333-3333'
cust_id => '1')
haystack[1] array (
email => abc@gmail.com'
phone => 444-333-5555'
cust_id => '2')
when i get a match on email address or phone I want to retrieve the cust_id?
I did this with a foreach loop and it took for ever. There are around 130,000 entries in the array.
It took about 5 minutes to do 1000 rows against the array. I will have about 1.6 million rows to process. Anyone have a good suggestion on how to do this.

Any suggestion would be great.

Re: Validate and retrieve info Multidimension array

Posted: Thu Mar 10, 2011 10:57 pm
by Jonah Bron
trailrunner1 wrote:when i get a match on email address or phone I want to retrieve the cust_id?
You mean you want to search for a email address, and get it's corresponding ID?
trailrunner1 wrote:I did this with a foreach loop and it took for ever. There are around 130,000 entries in the array.
It took about 5 minutes to do 1000 rows against the array. I will have about 1.6 million rows to process. Anyone have a good suggestion on how to do this.
Assuming your code is well optimized, there really isn't a way to speed it up. But the answer is simple: put it into a database.