Refactoring and moving countdim() to Set::countDim()

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@3840 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
nate 2006-11-08 03:26:09 +00:00
parent 97753554c6
commit 13c579292a

View file

@ -175,9 +175,15 @@ class Set extends Object {
*/
function extract($data, $path) {
if (!is_array($path)) {
$path = explode('.', $path);
if (strpos($path, '/') !== 0 && strpos($path, './') === false) {
$path = explode('.', $path);
} else {
}
}
$tmp = array();
if (!is_array($path) || empty($path)) {
return null;
}
foreach($path as $i => $key) {
if (intval($key) > 0 || $key == '0') {
@ -201,6 +207,32 @@ class Set extends Object {
}
return $data;
}
function isEqual($val1, $val2 = null) {
if ($val2 == null && (is_a($this, 'set') || is_a($this, 'Set'))) {
$val2 = $val1;
$val1 = $this->get();
}
}
/**
* Counts the dimensions of an array
*
* @param array $array
* @return int The number of dimensions in $array
*/
function countDim($array = null) {
if ($array === null) {
$array = $this->get();
} elseif (is_object($array) && is_a($array, 'set')) {
$array = $array->get();
}
if (is_array(reset($array))) {
$return = Set::countDim(reset($array)) + 1;
} else {
$return = 1;
}
return $return;
}
}
?>