This repository has been archived on 2024-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
lnapp/classes/Object.php

43 lines
969 B
PHP
Raw Permalink Normal View History

<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This is class is for manupulating objects in general
*
* @package lnApp
* @category Helpers
* @author Deon George
2014-09-29 04:47:51 +00:00
* @copyright (c) 2009-2013 Deon George
* @license http://dev.leenooks.net/license.html
*/
class Object {
/**
* Provide an in_array capability for an array of Objects
*
* @param string Object Key that we are evaluating
* @param string Value for that Key
* @param array The array of objects
2013-12-26 10:39:49 +00:00
* @param boolean Traverse children
* @return boolean
*/
2013-12-26 10:39:49 +00:00
public static function in_array($key,$value,array $objects,$traverse=FALSE) {
if (! count($objects))
return FALSE;
2013-12-26 10:39:49 +00:00
foreach ($objects as $object) {
if (is_array($object)) {
if (! $traverse)
continue;
if (self::in_array($key,$value,$object,$traverse))
return TRUE;
}
if (isset($object->$key) AND $object->$key == $value)
return TRUE;
2013-12-26 10:39:49 +00:00
}
return FALSE;
}
}
?>