Take two:
[www-register-wizard.git] / helpers / array_helper.php
1 <?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');\r
2 /**\r
3  * CodeIgniter\r
4  *\r
5  * An open source application development framework for PHP 4.3.2 or newer\r
6  *\r
7  * @package             CodeIgniter\r
8  * @author              ExpressionEngine Dev Team\r
9  * @copyright   Copyright (c) 2008, EllisLab, Inc.\r
10  * @license             http://codeigniter.com/user_guide/license.html\r
11  * @link                http://codeigniter.com\r
12  * @since               Version 1.0\r
13  * @filesource\r
14  */\r
15 \r
16 // ------------------------------------------------------------------------\r
17 \r
18 /**\r
19  * CodeIgniter Array Helpers\r
20  *\r
21  * @package             CodeIgniter\r
22  * @subpackage  Helpers\r
23  * @category    Helpers\r
24  * @author              ExpressionEngine Dev Team\r
25  * @link                http://codeigniter.com/user_guide/helpers/array_helper.html\r
26  */\r
27 \r
28 // ------------------------------------------------------------------------\r
29 \r
30 /**\r
31  * Element\r
32  *\r
33  * Lets you determine whether an array index is set and whether it has a value.\r
34  * If the element is empty it returns FALSE (or whatever you specify as the default value.)\r
35  *\r
36  * @access      public\r
37  * @param       string\r
38  * @param       array\r
39  * @param       mixed\r
40  * @return      mixed   depends on what the array contains\r
41  */     \r
42 if ( ! function_exists('element'))\r
43 {\r
44         function element($item, $array, $default = FALSE)\r
45         {\r
46                 if ( ! isset($array[$item]) OR $array[$item] == "")\r
47                 {\r
48                         return $default;\r
49                 }\r
50 \r
51                 return $array[$item];\r
52         }       \r
53 }\r
54 \r
55 // ------------------------------------------------------------------------\r
56 \r
57 /**\r
58  * Random Element - Takes an array as input and returns a random element\r
59  *\r
60  * @access      public\r
61  * @param       array\r
62  * @return      mixed   depends on what the array contains\r
63  */     \r
64 if ( ! function_exists('random_element'))\r
65 {\r
66         function random_element($array)\r
67         {\r
68                 if ( ! is_array($array))\r
69                 {\r
70                         return $array;\r
71                 }\r
72                 return $array[array_rand($array)];\r
73         }       \r
74 }\r
75 \r
76 \r
77 /* End of file array_helper.php */\r
78 /* Location: ./system/helpers/array_helper.php */