PHP无限梯归
<?php
class Tree
{
// public $data=array();//所有节点值
// public $cateArray=array();//所有父节点
function Tree()
{
}
//setNode(目录ID,上级ID,目录名字);
function setNode ($id, $parent, $value){
$parent = $parent?$parent:0;
$this->data[$id] = $value;//获取当前ID对应的当前目录名
$this->cateArray[$id] = $parent;//获取当前ID对应的父分类ID
//echo $id."->".$this->cateArray[$id]."--".$this->data[$id]."<br>";
}
function getChilds($id=0)
{
$childArray=array();
$childs=$this->getChild($id);
foreach ($childs as $child)
{
$childArray[]=$child;
$childArray=array_merge($childArray,$this->getChilds($child));//id 递归 累加
}
return $childArray;
}
function getChild($id)
{
&nbs
相关文档:
一. 首先做一个简单的so文件:
/**
* hello.c
* To compile, use following commands:
* gcc -O -c -fPIC -o hello.o hello.c
* gcc -shared ......
一. 首先做一个简单的so文件:
/**
* hello.c
* To compile, use following commands:
* gcc -O -c -fPIC -o hello.o hello.c
* gcc -shared ......
基本概念
PHP 中的数组实际上是一个有序图。图是一种把 values 映射到 keys 的类型。因此既可以把php的数组当做普通数组使用,也可以用它来模拟字典、集合、栈、队列、树等多种其他数据结构。
数组的创建:
创建数组的一般格式为:$arrName = array( [key =>]value, ...),其中key 可以是 integer 或者 string,而val ......
在做邯郸房产网的时候遇到php获取checkbox的问题:asp获取表单中的复选框的值,直接就是以“,”(逗号)为分隔符的数组。php中确总是只获取最后一个复选框的值。
解决办法:
form表单的部分代码:
<input type="checkbox" name="frm_tag[]" id="frm_tag" value="1">1
<input type="checkbox" name=" ......