By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,751 Members | 1,216 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,751 IT Pros & Developers. It's quick & easy.

Object or Array??

P: n/a
Hello there...

I have a little issue here....

Which one is better(I think object) but would like to hear from someone more
experienced....

class Persons
{
var $name;
var $comments;
var $thoughts;
var $email;

some functions.....
}

object in array:

while($line = $result->FetchRow()) //using ADODB
{
$person[$line['id']] = &new Persons;
$person[$line['id']]->name = $line['name'];
$person[$line['id']]->thoughts = $line['thoughts'];
$person[$line['id']]->email = $line['email'];
$person[$line['id']]->comments = $line['comments'];
}

or plain array:

while($line = $result->FetchRow())

$person[$line['id']]=Array("name"=>$line['name'],"thoughts"=>$line['thoughts
'],"email"=>$line['email'],"comments"=>$line['comments']);

thanx and respect....

p.


Jul 16 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
"point" <po***@caanNOSPAMproduction.com> wrote
in message news:<bj*********@enews2.newsguy.com>...

Which one is better (I think object) but would like to hear
from someone more experienced....


Define "better". Better for what? Reusability? Go with objects.
Performance? Stick with arrays and stop using abstraction layers.

Cheers,
NC
Jul 16 '05 #2

P: n/a
Thanx for your oppinions....

I'm sticking with objects just wanted to hear your oppinions....

In my oppinion objects are more close(although more abstract) to human way
of thinking than the procedural programing.....

respect....

"point" <po***@caanNOSPAMproduction.com> wrote in message
news:bj*********@enews2.newsguy.com...
Hello there...

I have a little issue here....

Which one is better(I think object) but would like to hear from someone more experienced....

class Persons
{
var $name;
var $comments;
var $thoughts;
var $email;

some functions.....
}

object in array:

while($line = $result->FetchRow()) //using ADODB
{
$person[$line['id']] = &new Persons;
$person[$line['id']]->name = $line['name'];
$person[$line['id']]->thoughts = $line['thoughts'];
$person[$line['id']]->email = $line['email'];
$person[$line['id']]->comments = $line['comments'];
}

or plain array:

while($line = $result->FetchRow())

$person[$line['id']]=Array("name"=>$line['name'],"thoughts"=>$line['thoughts '],"email"=>$line['email'],"comments"=>$line['comments']);

thanx and respect....

p.

Jul 16 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.