mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-18 18:46:17 +00:00
fixing last commit
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@4496 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
2c837ffac2
commit
0fc79cdf6a
1 changed files with 16 additions and 7 deletions
|
@ -75,18 +75,27 @@ class Object{
|
|||
return $class;
|
||||
}
|
||||
/**
|
||||
* Return a value from an array list.
|
||||
* Return a value from an array list if the key exists.
|
||||
*
|
||||
* If a coma separated $list is passed arrays are numeric with the key of the first being 0
|
||||
* $list = 'no, yes' would translate to $list = array(0 => 'no', 1 => 'yes');
|
||||
*
|
||||
* If an array is used, keys can be strings example: array('no' => 0, 'yes' => 1);
|
||||
*
|
||||
* $list defaults to 0 = no 1 = yes if param is not passed
|
||||
*
|
||||
* @param string $selected
|
||||
* @param array $list
|
||||
* @return string the value of the array key
|
||||
* @param mixed $list can be an array or a coma separated list.
|
||||
* @return string the value of the array key or null if no match
|
||||
*/
|
||||
function enum($select, $list = array('no', 'yes')) {
|
||||
$return = null;
|
||||
if(is_array($list)){
|
||||
if (array_key_exists($select, $list)) {
|
||||
$return = $list[$select];
|
||||
}
|
||||
if(is_string($list)) {
|
||||
$list = explode(',', $list);
|
||||
}
|
||||
|
||||
if (array_key_exists($select, $list)) {
|
||||
$return = $list[$select];
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue