1 <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
5 * An open source application development framework for PHP 5.1.6 or newer
8 * @author ExpressionEngine Dev Team
9 * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
10 * @license http://codeigniter.com/user_guide/license.html
11 * @link http://codeigniter.com
16 // ------------------------------------------------------------------------
19 * CodeIgniter Array Helpers
21 * @package CodeIgniter
24 * @author ExpressionEngine Dev Team
25 * @link http://codeigniter.com/user_guide/helpers/array_helper.html
28 // ------------------------------------------------------------------------
33 * Lets you determine whether an array index is set and whether it has a value.
34 * If the element is empty it returns FALSE (or whatever you specify as the default value.)
40 * @return mixed depends on what the array contains
42 if ( ! function_exists('element'))
44 function element($item, $array, $default = FALSE)
46 if ( ! isset($array[$item]) OR $array[$item] == "")
55 // ------------------------------------------------------------------------
58 * Random Element - Takes an array as input and returns a random element
62 * @return mixed depends on what the array contains
64 if ( ! function_exists('random_element'))
66 function random_element($array)
68 if ( ! is_array($array))
73 return $array[array_rand($array)];
77 // --------------------------------------------------------------------
82 * Returns only the array items specified. Will return a default value if
89 * @return mixed depends on what the array contains
91 if ( ! function_exists('elements'))
93 function elements($items, $array, $default = FALSE)
97 if ( ! is_array($items))
99 $items = array($items);
102 foreach ($items as $item)
104 if (isset($array[$item]))
106 $return[$item] = $array[$item];
110 $return[$item] = $default;
118 /* End of file array_helper.php */
119 /* Location: ./system/helpers/array_helper.php */