Tuesday, 20 August 2013

which is most preferrable data structure to get output into, arrays or object ? and why?

which is most preferrable data structure to get output into, arrays or
object ? and why?

Does output format have any effect on the overall performance of a script?
For example we sometimes get the option to select an output format (either
array or object), in a php based cms.
The only difference I know between the two is:
If we select array, we use
$example['key1'] = $dummydata;
but if output format is "object", we use
$example->key1 = $dummydata;
Is this the only reason (just the accessibility) why we should one of the
options over the other? Or there are other things to take into account
too? Which format is better between these? Example this is a code snippet
from wordpress where we get option to choose output type
$wpdb->get_row('query', output_type, row_offset);
$sql = "select * from ".$wpdb->prefix."sampletable where user_id
=".$user->ID;
$result_set = $wpdb->get_row($sql, ARRAY_A);

No comments:

Post a Comment