1 <html xmlns=
"http://www.w3.org/1999/xhtml" xml:
lang=
"en">
3 <title>CarbonPHP Documentation
</title>
4 <style type=
"text/css">
11 background: transparent
;
12 border-bottom: 1px dotted
#666;
14 text-decoration: none
;
22 font-family: "Lucida Sans Unicode", "Lucida Grande";
44 margin: 10px 0 10px 0;
45 list-style-position: inside
;
53 border: 1px dotted
#444;
61 border: 1px solid
#ccc;
72 <h1>Array Utility
</h1>
74 <p>The Array utlity contains functions that help when working with arrays. You load this utility using the
75 following piece of code.
</p>
78 $this-
>load-
>utility('array');
85 <p>This lets you fetch an item from the array. The function tests whether the array index is set and whether
86 it has a value. If a value exists it is returned. If a value does not exist if returns
<b>false
</b>, or whatever
87 is specified in the default value parameter.
</p>
90 $array = array('color' =
>; 'red', 'shape' =
> 'round', 'size' =
> '');
<br />
92 // returns
"red"<br />
93 echo element('color', $array);
<br />
96 echo element('size', $array, NULL);
100 <div class=
"content">
101 <h1>random_element()
</h1>
103 <p>Takes an array as input and returns a random element from it.
</p>
105 <div class=
"example">
106 $quotes = array(
<br />
107 "I find that the harder I work, the more luck I seem to have. - Thomas Jefferson",
<br />
108 "Don't stay in bed, unless you can make money in bed. - George Burns",
<br />
109 "We didn't lose the game; we just ran out of time. - Vince Lombardi",
<br />
110 "If everything seems under control, you're not going fast enough. - Mario Andretti",
<br />
111 "Reality is merely an illusion, albeit a very persistent one. - Albert Einstein",
<br />
112 "Chance favors the prepared mind - Louis Pasteur"<br />
115 echo random_element($quotes);
<br />