![]() |
array helper - element() - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Development (https://forum.codeigniter.com/forumdisplay.php?fid=6) +--- Forum: Issues (https://forum.codeigniter.com/forumdisplay.php?fid=19) +--- Thread: array helper - element() (/showthread.php?tid=62201) |
array helper - element() - ghibellino - 06-18-2015 Moving to 3.0 I found that the function element() doesn't check if the 2nd parameter is an array as in the 2.0, giving error. better to change in: function element($item, $array, $default = NULL) { return is_array($array) ? (array_key_exists($item, $array) ? $array[$item] : $default) : $default; } |