/lenasys/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/lenasys/trunk

« back to all changes in this revision

Viewing changes to codeigniter/system/helpers/array_helper.php

  • Committer: galaxyAbstractor
  • Date: 2013-04-10 15:49:32 UTC
  • mto: (19.1.5 lenasys)
  • mto: This revision was merged to the branch mainline in revision 23.
  • Revision ID: galaxyabstractor@gmail.com-20130410154932-4vizlzk0ar5gykvi
* Added an simple admin panel to the codeviewer-cmssy stuff
* Redesigned a bit like the mockups - still stuff to come
* Implemented the codeviewer + admin panel again using the Framework CodeIgniter instead 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
 
2
/**
 
3
 * CodeIgniter
 
4
 *
 
5
 * An open source application development framework for PHP 5.1.6 or newer
 
6
 *
 
7
 * @package             CodeIgniter
 
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
 
12
 * @since               Version 1.0
 
13
 * @filesource
 
14
 */
 
15
 
 
16
// ------------------------------------------------------------------------
 
17
 
 
18
/**
 
19
 * CodeIgniter Array Helpers
 
20
 *
 
21
 * @package             CodeIgniter
 
22
 * @subpackage  Helpers
 
23
 * @category    Helpers
 
24
 * @author              ExpressionEngine Dev Team
 
25
 * @link                http://codeigniter.com/user_guide/helpers/array_helper.html
 
26
 */
 
27
 
 
28
// ------------------------------------------------------------------------
 
29
 
 
30
/**
 
31
 * Element
 
32
 *
 
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.)
 
35
 *
 
36
 * @access      public
 
37
 * @param       string
 
38
 * @param       array
 
39
 * @param       mixed
 
40
 * @return      mixed   depends on what the array contains
 
41
 */
 
42
if ( ! function_exists('element'))
 
43
{
 
44
        function element($item, $array, $default = FALSE)
 
45
        {
 
46
                if ( ! isset($array[$item]) OR $array[$item] == "")
 
47
                {
 
48
                        return $default;
 
49
                }
 
50
 
 
51
                return $array[$item];
 
52
        }
 
53
}
 
54
 
 
55
// ------------------------------------------------------------------------
 
56
 
 
57
/**
 
58
 * Random Element - Takes an array as input and returns a random element
 
59
 *
 
60
 * @access      public
 
61
 * @param       array
 
62
 * @return      mixed   depends on what the array contains
 
63
 */
 
64
if ( ! function_exists('random_element'))
 
65
{
 
66
        function random_element($array)
 
67
        {
 
68
                if ( ! is_array($array))
 
69
                {
 
70
                        return $array;
 
71
                }
 
72
 
 
73
                return $array[array_rand($array)];
 
74
        }
 
75
}
 
76
 
 
77
// --------------------------------------------------------------------
 
78
 
 
79
/**
 
80
 * Elements
 
81
 *
 
82
 * Returns only the array items specified.  Will return a default value if
 
83
 * it is not set.
 
84
 *
 
85
 * @access      public
 
86
 * @param       array
 
87
 * @param       array
 
88
 * @param       mixed
 
89
 * @return      mixed   depends on what the array contains
 
90
 */
 
91
if ( ! function_exists('elements'))
 
92
{
 
93
        function elements($items, $array, $default = FALSE)
 
94
        {
 
95
                $return = array();
 
96
                
 
97
                if ( ! is_array($items))
 
98
                {
 
99
                        $items = array($items);
 
100
                }
 
101
                
 
102
                foreach ($items as $item)
 
103
                {
 
104
                        if (isset($array[$item]))
 
105
                        {
 
106
                                $return[$item] = $array[$item];
 
107
                        }
 
108
                        else
 
109
                        {
 
110
                                $return[$item] = $default;
 
111
                        }
 
112
                }
 
113
 
 
114
                return $return;
 
115
        }
 
116
}
 
117
 
 
118
/* End of file array_helper.php */
 
119
/* Location: ./system/helpers/array_helper.php */
 
 
b'\\ No newline at end of file'