Which one is better from performance view (CPU usage and etc)? using too many Variables or a single Associative Array or generally an Array?
This one:
$ld_linkdump_title = get_option('ld_linkdump_title');
$ld_linkdump_widget_title = get_option('ld_linkdump_widget_title');
$nw_option = get_option('ld_open_nw');
$ld_open_branding = get_option('ld_open_branding');
$ld_stylesheet_option = get_option('ld_stylesheet');
$ld_number_of_links = get_option('ld_number_of_links');
$ld_number_of_links_widget = get_option('ld_number_of_links_widget');
$ld_number_of_rss_links = get_option('ld_number_of_rss_links');
$ld_number_of_links_be = get_option('ld_number_of_links_be');
$ld_repeated_link = get_option('ld_repeated_link');
$ld_linkdump_fd = get_option('ld_linkdump_fd');
$ld_linkdump_rss_desc = get_option('ld_linkdump_rss_desc');
$ld_branding_bg = get_option('ld_branding_bg');
$ld_archive_days = get_option('ld_archive_days');
$ld_archive_pid = get_option('ld_archive_pid');
$ld_show_counter = get_option('ld_show_counter');
$ld_show_description = get_option('ld_show_description');
$ld_show_description_w = get_option('ld_show_description_w');
$ld_send_notification = get_option('ld_send_notification');
$ld_auto_approve = get_option('ld_auto_approve');
$ld_short_url = get_option('ld_short_url');
or this:
$options['ld_linkdump_title'] = get_option('ld_linkdump_title');
$options['ld_linkdump_widget_title'] = get_option('ld_linkdump_widget_title');
$options['nw_option'] = get_option('ld_open_nw');
.
.
.
I don't think you should consider this from a performance standpoint, rather, look at it from a readability standpoint. The second version collects, well, a collection of things, into a single storage mechanism; from a readability standpoint it's superior.
Not that it matters, but from a performance standpoint I can't imagine the second one costs much, if anything, certainly not enough to overcome the readability benefit.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With