summaryrefslogtreecommitdiffstats
path: root/system/helpers/array_helper.php
diff options
context:
space:
mode:
authorAndrey Andreev <narf@bofh.bg>2012-01-06 13:41:50 +0100
committerAndrey Andreev <narf@bofh.bg>2012-01-06 13:41:50 +0100
commitf1b43d43385c81788dab9103a4f9be7e02432852 (patch)
treec53fb3270f3e7c71b80d0e370f2f00f04ef7a141 /system/helpers/array_helper.php
parent20b4fa2fc12d0630aa8c5d9ce09623e58d98f9ca (diff)
Improve array, captcha & cookie helpers
Diffstat (limited to 'system/helpers/array_helper.php')
-rw-r--r--system/helpers/array_helper.php27
1 files changed, 7 insertions, 20 deletions
diff --git a/system/helpers/array_helper.php b/system/helpers/array_helper.php
index c46c4d103..881f57db3 100644
--- a/system/helpers/array_helper.php
+++ b/system/helpers/array_helper.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -77,12 +77,7 @@ if ( ! function_exists('random_element'))
{
function random_element($array)
{
- if ( ! is_array($array))
- {
- return $array;
- }
-
- return $array[array_rand($array)];
+ return (is_array($array)) ? $array[array_rand($array)] : $array;
}
}
@@ -105,22 +100,14 @@ if ( ! function_exists('elements'))
function elements($items, $array, $default = FALSE)
{
$return = array();
-
if ( ! is_array($items))
{
$items = array($items);
}
-
+
foreach ($items as $item)
{
- if (isset($array[$item]))
- {
- $return[$item] = $array[$item];
- }
- else
- {
- $return[$item] = $default;
- }
+ $return[$item] = (isset($array[$item])) ? $array[$item] : $default;
}
return $return;
@@ -128,4 +115,4 @@ if ( ! function_exists('elements'))
}
/* End of file array_helper.php */
-/* Location: ./system/helpers/array_helper.php */ \ No newline at end of file
+/* Location: ./system/helpers/array_helper.php */