function typeIndex()
{
if (!$this->parent) {
return -1;
} else {
$index = -1;
//foreach($this->parent->children as &$c) {
// if (strcasecmp($this->tag, $c->tag) === 0) {
// ++$index;
// }
// if ($c === $this) {
// return $index;
// }
//}
foreach (array_keys($this->parent->children) as $k) {
if (strcasecmp($this->tag, $this->parent->children[$k]->tag) === 0) {
++$index;
}
if ($this->parent->children[$k] === $this) {
return $index;
}
}
return -1;
}
}