1 : <?php
2 :
3 : /**
4 : * Class with methods for array manipulation
5 : */
6 : class CorujaArrayManipulation
7 : {
8 :
9 : /**
10 : * Returns the value of $strKey key of $arrElement array or
11 : * $mixNotFound in case the key doesn't exist
12 : *
13 : * @param Array $arrElement Array under manipulation
14 : * @param string $strKey Key of desired value
15 : * @param unknown $mixNotFound Value returned in case the key was not found
16 : * @return unknown Field value
17 : * @example $arrEx = array('a','b'); getArrayField($arrEx,1);
18 : */
19 : public static function getArrayField( $arrElement, $strKey = "" , $mixNotFound = NULL )
20 : {
21 10 : $arrElement = (array) $arrElement;
22 10 : if ( isset( $arrElement[ (string) $strKey ] ) )
23 10 : {
24 3 : return $arrElement[ (string) $strKey ];
25 : }
26 : else
27 : {
28 7 : return $mixNotFounded;
29 : }
30 : }
31 :
32 : }
33 :
34 :
35 : ?>
|