![]() |
array_alternator helper, addition to array_helper - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22) +--- Thread: array_alternator helper, addition to array_helper (/showthread.php?tid=27972) |
array_alternator helper, addition to array_helper - El Forum - 02-25-2010 [eluser]cahva[/eluser] I feel silly posting this as its almost the same code than alternator() function in string helper but for array. I needed one and here it is: application/helpers/MY_array_helper.php Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); I used this for my project where I needed(well I didnt need to but wanted to ![]() And Yay!, got Overall performance score 90 (Grade A) in Yslow and 96 points out of 100 in google Page Speed for my site with this(with other optimizations ofcourse) ![]() For example I had this set in config: Code: $config['asset_urls'] = array( ..and then used in views like this: Code: <img src="<?php echo theme_url('img/buttons/btn_1.png') ?>" alt="btn1" /> theme_url() is just a helper that I use and it contains the usage of array_alternator: Code: function theme_url($uri = '') Oh.. And if someone plans on using that theme_url function, just make sure your $config['base_url'] is set to '/' or '/my_app/' for example. So no full url to your site. Wow.. I intended to write short post but failed miserably and got sidetracked ![]() |