123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- <?php
- defined('BASEPATH') OR exit('No direct script access allowed');
- if ( ! function_exists('element'))
- {
-
- function element($item, array $array, $default = NULL)
- {
- return array_key_exists($item, $array) ? $array[$item] : $default;
- }
- }
- if ( ! function_exists('random_element'))
- {
-
- function random_element($array)
- {
- return is_array($array) ? $array[array_rand($array)] : $array;
- }
- }
- if ( ! function_exists('elements'))
- {
-
- function elements($items, array $array, $default = NULL)
- {
- $return = array();
- is_array($items) OR $items = array($items);
- foreach ($items as $item)
- {
- $return[$item] = array_key_exists($item, $array) ? $array[$item] : $default;
- }
- return $return;
- }
- }
|