Jump to content

Array problem


hvle

Recommended Posts

hi guys,

I have 2 ways of storing record in an array, and I wanna know which one is better (efficiency).

method 1:
$book[] = array('name' => 'name1', 'email' => 'email1');
$book[] = array('name' => 'name2', 'email' => 'email2');
$book[] = array('name' => 'name3', 'email' => 'email3');

method 2:
$book['name'] = array('name1', 'name2', 'name3');
$book['email'] = array('email1', 'email2', 'email3');


thank you very much for any suggestion
Link to comment
https://forums.phpfreaks.com/topic/13854-array-problem/
Share on other sites

method 1 may seem very easy to manipulate, but I got a lot of trouble w/ sorting, and finding out duplication.

A hash method, can you explain what it is?

The # of records are reasonably small considering # of addresses in your address book, so the number is around 5 to 200.  I need to do some database operation like sorting, filtering duplication, insertion.  These operations done inside script, so no database involved.

thanks

Link to comment
https://forums.phpfreaks.com/topic/13854-array-problem/#findComment-53951
Share on other sites

[quote author=Buyocat link=topic=99667.msg392609#msg392609 date=1152201958]
I'd go one step further, if you can, and make it:
[code]
array(book => array(book1 => array(name => Catch22, email =>someemail)...)))
[/code]
[/quote]
can you point out the advantage with this way cuz I can not see it.
Link to comment
https://forums.phpfreaks.com/topic/13854-array-problem/#findComment-53954
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.