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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.