CorujaArrayManipulation Class Reference

List of all members.

Static Public Member Functions

static getArrayField (array $arrElement, $mixKey, $mixNotFound=null)


Detailed Description

Class with methods for array manipulation
Author:
Thiago Henrique Ramos da Mata <thiago.henrique.mata@gmail.com>

Definition at line 11 of file CorujaArrayManipulation.class.php.


Member Function Documentation

static getArrayField ( array $  arrElement,
mixKey,
mixNotFound = null 
) [static]

Returns the value of $mixKey key of $arrElement array or $mixNotFound in case the key doesn't exist

Parameters:
Array $arrElement Array under manipulation
unknown $mixKey Key of desired value
unknown $mixNotFound Value returned in case the key was not found
Returns:
unknown Field value
Example:
 \1 
returns
 true 
.... $arrEx = array('a','b'); CorujaArrayManipulation::getArrayField($arrEx,1); // returns 'b'
Assert:
( array( "a" => 1 , "b" => 2 ) , "a" ) = 1
Assert:
( array( "a" => 1 , "b" => 2 ) , "x" ) = null
Assert:
( array( "a" => new stdClass() , "b" => new stdClass() ) , new stdClass() ) = new stdClass()
Assert:
( array() , "something" ) = null
Assert:
( array() , "something" , "nothing" ) = "nothing"

Definition at line 30 of file CorujaArrayManipulation.class.php.

Referenced by CorujaDebug::getBackTraceCaller(), CodeReflectionFile::getFileBit(), CorujaClassManipulation::getNamespaceFromClassDefinition(), CorujaArrayManipulationTest::testGetArrayFieldWithExistingKey(), CorujaArrayManipulationTest::testGetArrayFieldWithNoKey(), CorujaArrayManipulationTest::testGetArrayFieldWithNoneArray(), CorujaArrayManipulationTest::testGetArrayFieldWithNoneExistingKey(), CorujaArrayManipulationTest::testGetArrayFieldWithNoneExistingKeyAndThirdParameter(), CorujaArrayManipulationTest::testGetArrayFieldWithNullArray(), and CorujaArrayManipulationTest::testGetArrayFieldWithNullKey().

00031         {
00032                 if ( array_key_exists( $mixKey , $arrElement ) )
00033                 {
00034                         return $arrElement[ $mixKey ];
00035                 }
00036                 else
00037                 {
00038                         return $mixNotFound;
00039                 }
00040         }


The documentation for this class was generated from the following file:

Generated on Thu Feb 3 03:55:03 2011 for CodeToDiagram by  doxygen 1.5.9