histogram: Make histograms crash less
[ninja.git] / application / helpers / arr.php
blobad1b4da5729a439a4ae67b324b5e7787aa18ba79
1 <?php defined('SYSPATH') OR die('No direct access allowed.');
2 /**
3 * Array Help class
4 */
5 class arr_Core
7 /**
8 * this just lets us safely access array variables
9 * that might not be set, optionally specifying a default
10 * to return in case the variable isn't found.
11 * Note that $k (for key) can be an array
13 public static function search($ary, $k, $def = false)
15 if (is_array($k))
16 $try = $k;
17 else
18 $try = array($k);
20 foreach ($try as $k)
21 if (isset($ary[$k]))
22 return $ary[$k];
24 return $def;