Validate and retrieve info Multidimension array

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
trailrunner1
Forum Newbie
Posts: 1
Joined: Thu Mar 10, 2011 8:54 pm

Validate and retrieve info Multidimension array

Post 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.
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Re: Validate and retrieve info Multidimension array

Post 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.
Post Reply