本文整理汇总了PHP中count_numeric_items函数的典型用法代码示例。如果您正苦于以下问题:PHP count_numeric_items函数的具体用法?PHP count_numeric_items怎么用?PHP count_numeric_items使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了count_numeric_items函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: open
function open($parser, $tag, $attributes){
$this->data = ''; #stores temporary cdata
$this->last_opened_tag = $tag;
if(is_array($this->parent) and array_key_exists($tag,$this->parent)){ #if you've seen this tag before
if(is_array($this->parent[$tag]) and array_key_exists(0,$this->parent[$tag])){ #if the keys are numeric
#this is the third or later instance of $tag we've come across
$key = count_numeric_items($this->parent[$tag]);
}else{
#this is the second instance of $tag that we've seen. shift around
if(array_key_exists("$tag attr",$this->parent)){
$arr = array('0 attr'=>&$this->parent["$tag attr"], &$this->parent[$tag]);
unset($this->parent["$tag attr"]);
}else{
$arr = array(&$this->parent[$tag]);
}
$this->parent[$tag] = &$arr;
$key = 1;
}
$this->parent = &$this->parent[$tag];
}else{
$key = $tag;
}
if($attributes) $this->parent["$key attr"] = $attributes;
$this->parent = &$this->parent[$key];
$this->stack[] = &$this->parent;
}
示例2: open
function open(&$parser, $tag, $attributes)
{
$this->data = '';
$this->last_opened_tag = $tag;
if (is_array($this->parent) and array_key_exists($tag, $this->parent)) {
if (is_array($this->parent[$tag]) and array_key_exists(0, $this->parent[$tag])) {
$key = count_numeric_items($this->parent[$tag]);
} else {
if (array_key_exists($tag . '_attr', $this->parent)) {
$arr = array('0_attr' => &$this->parent[$tag . '_attr'], &$this->parent[$tag]);
unset($this->parent[$tag . '_attr']);
} else {
$arr = array(&$this->parent[$tag]);
}
$this->parent[$tag] =& $arr;
$key = 1;
}
$this->parent =& $this->parent[$tag];
} else {
$key = $tag;
}
if ($attributes) {
$this->parent[$key . '_attr'] = $attributes;
}
$this->parent =& $this->parent[$key];
$this->stack[] =& $this->parent;
}
示例3: open
function open(&$parser, $tag, $attributes)
{
$this->data = '';
#stores temporary cdata
$this->last_opened_tag = $tag;
$key = count_numeric_items($this->parent[$tag]);
if ($attributes) {
$this->parent[$tag]["{$key} attr"] = $attributes;
}
$this->parent[$tag][$key] = array();
$this->parent =& $this->parent[$tag][$key];
$this->stack[] =& $this->parent;
}
示例4: open
function open($parser, $tag, $attributes)
{
#echo "Opening tag $tag<br>\n";
$this->data = "";
$this->last_opened_tag = $tag;
#tag is a string
if (array_key_exists($tag, $this->parent)) {
#echo "There's already an instance of '$tag' at the current level ($level)<br>\n";
if (is_array($this->parent[$tag]) and array_key_exists(0, $this->parent[$tag])) {
#if the keys are numeric
#need to make sure they're numeric (account for attributes)
$key = count_numeric_items($this->parent[$tag]);
#echo "There are $key instances: the keys are numeric.<br>\n";
} else {
#echo "There is only one instance. Shifting everything around<br>\n";
$temp =& $this->parent[$tag];
unset($this->parent[$tag]);
$this->parent[$tag][0] =& $temp;
if (array_key_exists("{$tag} attr", $this->parent)) {
#shift the attributes around too if they exist
$temp =& $this->parent["{$tag} attr"];
unset($this->parent["{$tag} attr"]);
$this->parent[$tag]["0 attr"] =& $temp;
}
$key = 1;
}
$this->parent =& $this->parent[$tag];
} else {
$key = $tag;
}
if ($attributes) {
$this->parent["{$key} attr"] = $attributes;
}
$this->parent[$key] = array();
$this->parent =& $this->parent[$key];
// Changed by Igor Borisov for PHP >= 5.4
// array_unshift($this->parents, &$this->parent); Original
array_unshift($this->parents, 0);
// Changed
$this->parents[0] =& $this->parent;
// Added
}
示例5: open
function open($parser, $tag, $attributes)
{
#echo "Opening tag $tag<br>\n";
$this->data = "";
$this->last_opened_tag = $tag;
#tag is a string
if (array_key_exists($tag, $this->parent)) {
#echo "There's already an instance of '$tag' at the current level ($level)<br>\n";
if (is_array($this->parent[$tag]) and array_key_exists(0, $this->parent[$tag])) {
#if the keys are numeric
#need to make sure they're numeric (account for attributes)
$key = count_numeric_items($this->parent[$tag]);
#echo "There are $key instances: the keys are numeric.<br>\n";
} else {
#echo "There is only one instance. Shifting everything around<br>\n";
$temp =& $this->parent[$tag];
unset($this->parent[$tag]);
$this->parent[$tag][0] =& $temp;
if (array_key_exists("{$tag} attr", $this->parent)) {
#shift the attributes around too if they exist
$temp =& $this->parent["{$tag} attr"];
unset($this->parent["{$tag} attr"]);
$this->parent[$tag]["0 attr"] =& $temp;
}
$key = 1;
}
$this->parent =& $this->parent[$tag];
} else {
$key = $tag;
}
if ($attributes) {
$this->parent["{$key} attr"] = $attributes;
}
$this->parent[$key] = array();
$this->parent =& $this->parent[$key];
// Can't unshift by reference, so insert dummy and replace it with reference afterwards
array_unshift($this->parents, NULL);
$this->parents[0] =& $this->parent;
}