解析thinkphp的左右值無(wú)限分類(lèi)
更新時(shí)間:2013年06月20日 17:37:55 作者:
本篇文章是對(duì)thinkphp的左右值無(wú)限分類(lèi)進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下
以前一直使用父子無(wú)限分類(lèi),這種分類(lèi)結(jié)構(gòu)清晰,使用也簡(jiǎn)單。但若分類(lèi)數(shù)量很大的話(huà),在查詢(xún)上性能不佳。比如在做導(dǎo)航菜單中,我要根據(jù)某一分類(lèi)查詢(xún)出整個(gè)分類(lèi)樹(shù)的話(huà)(祖輩)。
性能消耗是非常大的,要么做遞歸,要么做多次查詢(xún)。故,對(duì)于分類(lèi)的數(shù)據(jù)量很大的情況,我推薦使用左右值,以減少查詢(xún)上的麻煩。
_id
/**
+----------------------------------------------------------
* 構(gòu)造函數(shù)
* @access public
* @return void
+----------------------------------------------------------
*/
public function __construct($left,$right,$id){
parent::__construct();
$this->_left = $left;
$this->_right = $right;
$this->_id = $id;
}
/**
+----------------------------------------------------------
* 根據(jù)node$this->_id得到該node的所有值
* @access public
* @param $nodeId
* @return array
+----------------------------------------------------------
*/
public function getNodeById($nodeId)
{
if($nodeId>0)
{
return $this->getById($nodeId);
}
else
{
throw_exception('未知$this->_id');
return false;
}
}
/**
+----------------------------------------------------------
* 獲取父節(jié)點(diǎn),含直屬父類(lèi)(type=1),所有父類(lèi):type=0
* @access public
* @param $nodeId int 節(jié)點(diǎn)$this->_id
* @return $parentNode array()
+----------------------------------------------------------
*/
public function getParentNode($nodeId,$type = 0)
{
if($nodeId == 0) throw_exception('未知$this->_id');;
$currentNode = $this->getNodeById($nodeId);
if($currentNode)
{
$condition = " ".$this->_left.'<'.$currentNode[$this->_left].' and '.$this->_right.' >'.$currentNode[$this->_right]." ";
if($type ==1) //直屬父類(lèi)
{
return $this->where($condition)->order($this->_left." DESC")->limit(1)->find();
// $sql = "SELECT * FROM ".TABLE_NAME." WHERE {$condition} ORDER BY ".$this->_left." DESC LIMIT 1";
// return mysql_query($sql) or die(mysql_error());
}
else if($type ==0)
{
return $this->where($condition)->findAll();
// $sql = "SELECT * FROM ".TABLE_NAME." WHERE {$condition} ";
// return mysql_query($sql) or die(mysql_error());
}
}
else
{
return false;
}
}
/**
+----------------------------------------------------------
* 當(dāng)前節(jié)點(diǎn)下子孫節(jié)點(diǎn)總數(shù).子孫總數(shù)=(當(dāng)前節(jié)點(diǎn)的右值 - 當(dāng)前節(jié)點(diǎn)的左值-1)/2
* @access public
* @param $node_id int 節(jié)點(diǎn)$this->_id
* @return $amount int 該節(jié)點(diǎn)下的子孫總數(shù) *
+----------------------------------------------------------
*/
public function getChildCount($nodeId)
{
$currentNode = $this->getNodeById($nodeId);
if(!empty($currentNode))
{
return (int)($currentNode[$this->_right]-$currentNode[$this->_left] -1)/2;
}
}
/**
+----------------------------------------------------------
* 獲取當(dāng)前節(jié)點(diǎn)下所有子節(jié)點(diǎn)。 當(dāng) A子類(lèi)的右節(jié)點(diǎn)=B子類(lèi)左節(jié)點(diǎn)-1 則 A、B屬于同一級(jí)別
* @access public
* @param $curentId
* @param $type int 0:當(dāng)前節(jié)點(diǎn)下所有子類(lèi),1為當(dāng)前節(jié)點(diǎn)下一級(jí)子類(lèi)
* @return bool
+----------------------------------------------------------
*/
public function getChild($nodeId,$type=0)
{
$currentNode = $this->getNodeById($nodeId);
if($currentNode[$this->_left]-$currentNode[$this->_right] ==1)
{
return false; //當(dāng) 該節(jié)點(diǎn)左值 - 右值=1 時(shí),其下沒(méi)有子節(jié)點(diǎn)。
}
else
{
$condition = $this->_left.'>'.$currentNode[$this->_left].' and '.$this->_right .'<'.$currentNode[$this->_right];
$child = $this->where($condition)->findAll();
if($type == 0)//所有子類(lèi)
{
return $child;
}
else if($type ==1) //獲取當(dāng)前節(jié)點(diǎn)下一級(jí)分類(lèi)
{
$subArr = array(); //一級(jí)子類(lèi)
foreach ($child as $k=>$sub) {
//子類(lèi)的左節(jié)點(diǎn)=父類(lèi)左節(jié)點(diǎn)+1,則子類(lèi)為第一個(gè)子類(lèi)
if($sub[$this->_left]==$currentNode[$this->_left]+1)
{
//$right = $sub[$k][$this->_right]; //當(dāng)前節(jié)點(diǎn)的右節(jié)點(diǎn)
$firstSub = $sub; //當(dāng)前節(jié)點(diǎn)下第一個(gè)子類(lèi)
array_push($subArr,$firstSub); //子類(lèi)入棧
unset($child[$k]);
}
}
$rightVal = $firstSub[$this->_right]; //第一個(gè)子節(jié)點(diǎn)為比較標(biāo)志
$childCount = count($child);//剩余子節(jié)點(diǎn)數(shù)
for($i=0;$i<$childCount;$i++) //循環(huán)檢索出 同級(jí)子節(jié)點(diǎn)
{
foreach ($child as $key => $sub2) {
if($rightVal == $sub2[$this->_left]-1)
{
$rightVal = $sub2[$this->_right]; //把循環(huán)當(dāng)前的node的右節(jié)點(diǎn)當(dāng)做比較值
array_push($subArr,$sub2);
unset($child[$key]);
}
}
}
return $subArr;
}
}
}
/**
+----------------------------------------------------------
* 返回當(dāng)前節(jié)點(diǎn)的完整路徑
* @access public
* @param $nodeId
* @return array
+----------------------------------------------------------
*/
public function getSinglePath($nodeId)
{
$sql = "select parent.* from __TABLE__ as node,__TABLE__ as parent where node.{$this->_left} between parent.{$this->_left}
AND parent.{$this->_right} AND node.{$this->_id} = {$nodeId} order by parent.{$this->_left}";
// echo $sql;
return $this->query($sql);
}
/**
+----------------------------------------------------------
* 添加子節(jié)點(diǎn),分3種:0:在當(dāng)前節(jié)點(diǎn)下最后追加一個(gè)子節(jié)點(diǎn);1:在當(dāng)前節(jié)點(diǎn)下追加第一個(gè)子節(jié)點(diǎn);
2:在當(dāng)前節(jié)點(diǎn)下的某個(gè)子節(jié)點(diǎn)后追加
* @access public
* @param $currentId int
* @param $nodeName string 新節(jié)點(diǎn)名稱(chēng)
* @param $targetId int 追加到當(dāng)前節(jié)點(diǎn)下子節(jié)點(diǎn)的指定節(jié)點(diǎn)后
* @return bool
+----------------------------------------------------------
*/
public function addNode($nodeId,$newData,$type=0,$targetId=0)
{
if(empty($newData))
{
throw_exception('新分類(lèi)不能為空');
}
$currentNode = $this->getNodeById($nodeId);
switch ($type) {
case 0:
$leftNode = $currentNode[$this->_right]; //新節(jié)點(diǎn)的左值為父節(jié)點(diǎn)的右值
$rightNode = $leftNode+1;
break;
case 1:
$leftNode = $currentNode[$this->_left]+1; //新節(jié)點(diǎn)的左值為父節(jié)點(diǎn)的左值+1
$rightNode = $leftNode+1;
break;
case 2:
$otherNode = $this->getNodeById($targetId);
$leftNode = $otherNode[$this->_right]+1;
$rightNode = $leftNode+1;
default:
break;
}
// $sql = "UPDATE ".TABLE_NAME." SET ".$this->_right."=".$this->_right."+2 WHERE ".$this->_right." >= ".$leftNode;
// $sql2 = "UPDATE ".TABLE_NAME." SET ".$this->_left."=".$this->_left."+2 WHERE ".$this->_left.">".$leftNode;
$this->setInc($this->_right,$this->_right.">=".$leftNode,2); //把所有右值大于新節(jié)點(diǎn)左值的節(jié)點(diǎn)的右值+2,注意效率
$this->setInc($this->_left,$this->_left.">".$leftNode,2); //把所有大于新節(jié)點(diǎn)的左值+2
$newData[$this->_left] = (int)$leftNode;
$newData[$this->_right] =(int) $rightNode;
return $this->add($newData);
}
/**
+----------------------------------------------------------
* 刪除節(jié)點(diǎn)
* @access public
* @param type 操作類(lèi)型,默認(rèn)為0刪除當(dāng)前節(jié)點(diǎn)下的所有子節(jié)點(diǎn),1為刪除包括自身的節(jié)點(diǎn)
* @param $nodeId int 要?jiǎng)h除的$this->_id
* @return bool
+----------------------------------------------------------
*/
public function rmNode($nodeId,$type =1)
{
$currentNode = $this->getNodeById($nodeId);
if($type == 1) //刪除包含自身的節(jié)點(diǎn)
{
$sql = "DELETE FROM __TABLE__ WHERE ".$this->_left.">= {$currentNode[$this->_left]} AND ".$this->_right."<= {$currentNode[$this->_right]}";
$childCount = ($this->getChildCount($nodeId)+1)*2; //要更新的值
$sql2 = "UPDATE __TABLE__ SET ".$this->_right."=".$this->_right."-".$childCount." WHERE ".$this->_right.">".$currentNode[$this->_right];
$sql3 = "UPDATE __TABLE__ SET ".$this->_left."=".$this->_left."-".$childCount." WHERE ".$this->_left.">".$currentNode[$this->_left];
}
else //刪除當(dāng)前節(jié)點(diǎn)下的所有節(jié)點(diǎn)
{
$sql ="DELETE FROM __TABLE__ WHERE ".$this->_left."> {$currentNode[$this->_left]} AND ".$this->_right."< {$currentNode[$this->_right]}";
$childCount = $this->getChildCount($nodeId)*2; //要更新的值
$sql2 = "UPDATE __TABLE__ SET ".$this->_right."=".$this->_right ."-".$childCount." WHERE ".$this->_right.">=".$currentNode[$this->_right];
$sql3 = "UPDATE __TABLE__ SET ".$this->_left."=".$this->_left."-".$childCount." WHERE ".$this->_left.">".$currentNode[$this->_left];
}
$this->execute($sql);
$this->execute($sql2);
$this->execute($sql3);
return true;
}
/**
+----------------------------------------------------------
* 修改節(jié)點(diǎn),名稱(chēng)等
* @access public
* @param $newData array()必須含有 要修改的$this->_id,k-v必須對(duì)齊,如arr['node_name'] = '商品'
* @return bool
+----------------------------------------------------------
*/
public function modiNode($newData)
{
if(!empty($newData))
{
$id = $newData[$this->_id];
unset($newData[$this->_id]);
return $this->save($newData,$this->_id.'='.$id);
}
}
}
?>
性能消耗是非常大的,要么做遞歸,要么做多次查詢(xún)。故,對(duì)于分類(lèi)的數(shù)據(jù)量很大的情況,我推薦使用左右值,以減少查詢(xún)上的麻煩。
復(fù)制代碼 代碼如下:
_id
/**
+----------------------------------------------------------
* 構(gòu)造函數(shù)
* @access public
* @return void
+----------------------------------------------------------
*/
public function __construct($left,$right,$id){
parent::__construct();
$this->_left = $left;
$this->_right = $right;
$this->_id = $id;
}
/**
+----------------------------------------------------------
* 根據(jù)node$this->_id得到該node的所有值
* @access public
* @param $nodeId
* @return array
+----------------------------------------------------------
*/
public function getNodeById($nodeId)
{
if($nodeId>0)
{
return $this->getById($nodeId);
}
else
{
throw_exception('未知$this->_id');
return false;
}
}
/**
+----------------------------------------------------------
* 獲取父節(jié)點(diǎn),含直屬父類(lèi)(type=1),所有父類(lèi):type=0
* @access public
* @param $nodeId int 節(jié)點(diǎn)$this->_id
* @return $parentNode array()
+----------------------------------------------------------
*/
public function getParentNode($nodeId,$type = 0)
{
if($nodeId == 0) throw_exception('未知$this->_id');;
$currentNode = $this->getNodeById($nodeId);
if($currentNode)
{
$condition = " ".$this->_left.'<'.$currentNode[$this->_left].' and '.$this->_right.' >'.$currentNode[$this->_right]." ";
if($type ==1) //直屬父類(lèi)
{
return $this->where($condition)->order($this->_left." DESC")->limit(1)->find();
// $sql = "SELECT * FROM ".TABLE_NAME." WHERE {$condition} ORDER BY ".$this->_left." DESC LIMIT 1";
// return mysql_query($sql) or die(mysql_error());
}
else if($type ==0)
{
return $this->where($condition)->findAll();
// $sql = "SELECT * FROM ".TABLE_NAME." WHERE {$condition} ";
// return mysql_query($sql) or die(mysql_error());
}
}
else
{
return false;
}
}
/**
+----------------------------------------------------------
* 當(dāng)前節(jié)點(diǎn)下子孫節(jié)點(diǎn)總數(shù).子孫總數(shù)=(當(dāng)前節(jié)點(diǎn)的右值 - 當(dāng)前節(jié)點(diǎn)的左值-1)/2
* @access public
* @param $node_id int 節(jié)點(diǎn)$this->_id
* @return $amount int 該節(jié)點(diǎn)下的子孫總數(shù) *
+----------------------------------------------------------
*/
public function getChildCount($nodeId)
{
$currentNode = $this->getNodeById($nodeId);
if(!empty($currentNode))
{
return (int)($currentNode[$this->_right]-$currentNode[$this->_left] -1)/2;
}
}
/**
+----------------------------------------------------------
* 獲取當(dāng)前節(jié)點(diǎn)下所有子節(jié)點(diǎn)。 當(dāng) A子類(lèi)的右節(jié)點(diǎn)=B子類(lèi)左節(jié)點(diǎn)-1 則 A、B屬于同一級(jí)別
* @access public
* @param $curentId
* @param $type int 0:當(dāng)前節(jié)點(diǎn)下所有子類(lèi),1為當(dāng)前節(jié)點(diǎn)下一級(jí)子類(lèi)
* @return bool
+----------------------------------------------------------
*/
public function getChild($nodeId,$type=0)
{
$currentNode = $this->getNodeById($nodeId);
if($currentNode[$this->_left]-$currentNode[$this->_right] ==1)
{
return false; //當(dāng) 該節(jié)點(diǎn)左值 - 右值=1 時(shí),其下沒(méi)有子節(jié)點(diǎn)。
}
else
{
$condition = $this->_left.'>'.$currentNode[$this->_left].' and '.$this->_right .'<'.$currentNode[$this->_right];
$child = $this->where($condition)->findAll();
if($type == 0)//所有子類(lèi)
{
return $child;
}
else if($type ==1) //獲取當(dāng)前節(jié)點(diǎn)下一級(jí)分類(lèi)
{
$subArr = array(); //一級(jí)子類(lèi)
foreach ($child as $k=>$sub) {
//子類(lèi)的左節(jié)點(diǎn)=父類(lèi)左節(jié)點(diǎn)+1,則子類(lèi)為第一個(gè)子類(lèi)
if($sub[$this->_left]==$currentNode[$this->_left]+1)
{
//$right = $sub[$k][$this->_right]; //當(dāng)前節(jié)點(diǎn)的右節(jié)點(diǎn)
$firstSub = $sub; //當(dāng)前節(jié)點(diǎn)下第一個(gè)子類(lèi)
array_push($subArr,$firstSub); //子類(lèi)入棧
unset($child[$k]);
}
}
$rightVal = $firstSub[$this->_right]; //第一個(gè)子節(jié)點(diǎn)為比較標(biāo)志
$childCount = count($child);//剩余子節(jié)點(diǎn)數(shù)
for($i=0;$i<$childCount;$i++) //循環(huán)檢索出 同級(jí)子節(jié)點(diǎn)
{
foreach ($child as $key => $sub2) {
if($rightVal == $sub2[$this->_left]-1)
{
$rightVal = $sub2[$this->_right]; //把循環(huán)當(dāng)前的node的右節(jié)點(diǎn)當(dāng)做比較值
array_push($subArr,$sub2);
unset($child[$key]);
}
}
}
return $subArr;
}
}
}
/**
+----------------------------------------------------------
* 返回當(dāng)前節(jié)點(diǎn)的完整路徑
* @access public
* @param $nodeId
* @return array
+----------------------------------------------------------
*/
public function getSinglePath($nodeId)
{
$sql = "select parent.* from __TABLE__ as node,__TABLE__ as parent where node.{$this->_left} between parent.{$this->_left}
AND parent.{$this->_right} AND node.{$this->_id} = {$nodeId} order by parent.{$this->_left}";
// echo $sql;
return $this->query($sql);
}
/**
+----------------------------------------------------------
* 添加子節(jié)點(diǎn),分3種:0:在當(dāng)前節(jié)點(diǎn)下最后追加一個(gè)子節(jié)點(diǎn);1:在當(dāng)前節(jié)點(diǎn)下追加第一個(gè)子節(jié)點(diǎn);
2:在當(dāng)前節(jié)點(diǎn)下的某個(gè)子節(jié)點(diǎn)后追加
復(fù)制代碼 代碼如下:
* @access public
* @param $currentId int
* @param $nodeName string 新節(jié)點(diǎn)名稱(chēng)
* @param $targetId int 追加到當(dāng)前節(jié)點(diǎn)下子節(jié)點(diǎn)的指定節(jié)點(diǎn)后
* @return bool
+----------------------------------------------------------
*/
public function addNode($nodeId,$newData,$type=0,$targetId=0)
{
if(empty($newData))
{
throw_exception('新分類(lèi)不能為空');
}
$currentNode = $this->getNodeById($nodeId);
switch ($type) {
case 0:
$leftNode = $currentNode[$this->_right]; //新節(jié)點(diǎn)的左值為父節(jié)點(diǎn)的右值
$rightNode = $leftNode+1;
break;
case 1:
$leftNode = $currentNode[$this->_left]+1; //新節(jié)點(diǎn)的左值為父節(jié)點(diǎn)的左值+1
$rightNode = $leftNode+1;
break;
case 2:
$otherNode = $this->getNodeById($targetId);
$leftNode = $otherNode[$this->_right]+1;
$rightNode = $leftNode+1;
default:
break;
}
// $sql = "UPDATE ".TABLE_NAME." SET ".$this->_right."=".$this->_right."+2 WHERE ".$this->_right." >= ".$leftNode;
// $sql2 = "UPDATE ".TABLE_NAME." SET ".$this->_left."=".$this->_left."+2 WHERE ".$this->_left.">".$leftNode;
$this->setInc($this->_right,$this->_right.">=".$leftNode,2); //把所有右值大于新節(jié)點(diǎn)左值的節(jié)點(diǎn)的右值+2,注意效率
$this->setInc($this->_left,$this->_left.">".$leftNode,2); //把所有大于新節(jié)點(diǎn)的左值+2
$newData[$this->_left] = (int)$leftNode;
$newData[$this->_right] =(int) $rightNode;
return $this->add($newData);
}
/**
+----------------------------------------------------------
* 刪除節(jié)點(diǎn)
* @access public
* @param type 操作類(lèi)型,默認(rèn)為0刪除當(dāng)前節(jié)點(diǎn)下的所有子節(jié)點(diǎn),1為刪除包括自身的節(jié)點(diǎn)
* @param $nodeId int 要?jiǎng)h除的$this->_id
* @return bool
+----------------------------------------------------------
*/
public function rmNode($nodeId,$type =1)
{
$currentNode = $this->getNodeById($nodeId);
if($type == 1) //刪除包含自身的節(jié)點(diǎn)
{
$sql = "DELETE FROM __TABLE__ WHERE ".$this->_left.">= {$currentNode[$this->_left]} AND ".$this->_right."<= {$currentNode[$this->_right]}";
$childCount = ($this->getChildCount($nodeId)+1)*2; //要更新的值
$sql2 = "UPDATE __TABLE__ SET ".$this->_right."=".$this->_right."-".$childCount." WHERE ".$this->_right.">".$currentNode[$this->_right];
$sql3 = "UPDATE __TABLE__ SET ".$this->_left."=".$this->_left."-".$childCount." WHERE ".$this->_left.">".$currentNode[$this->_left];
}
else //刪除當(dāng)前節(jié)點(diǎn)下的所有節(jié)點(diǎn)
{
$sql ="DELETE FROM __TABLE__ WHERE ".$this->_left."> {$currentNode[$this->_left]} AND ".$this->_right."< {$currentNode[$this->_right]}";
$childCount = $this->getChildCount($nodeId)*2; //要更新的值
$sql2 = "UPDATE __TABLE__ SET ".$this->_right."=".$this->_right ."-".$childCount." WHERE ".$this->_right.">=".$currentNode[$this->_right];
$sql3 = "UPDATE __TABLE__ SET ".$this->_left."=".$this->_left."-".$childCount." WHERE ".$this->_left.">".$currentNode[$this->_left];
}
$this->execute($sql);
$this->execute($sql2);
$this->execute($sql3);
return true;
}
/**
+----------------------------------------------------------
* 修改節(jié)點(diǎn),名稱(chēng)等
* @access public
* @param $newData array()必須含有 要修改的$this->_id,k-v必須對(duì)齊,如arr['node_name'] = '商品'
* @return bool
+----------------------------------------------------------
*/
public function modiNode($newData)
{
if(!empty($newData))
{
$id = $newData[$this->_id];
unset($newData[$this->_id]);
return $this->save($newData,$this->_id.'='.$id);
}
}
}
?>
您可能感興趣的文章:
- ThinkPHP無(wú)限級(jí)分類(lèi)原理實(shí)現(xiàn)留言與回復(fù)功能實(shí)例
- thinkphp實(shí)現(xiàn)無(wú)限分類(lèi)(使用遞歸)
- thinkPHP實(shí)現(xiàn)遞歸循環(huán)欄目并按照樹(shù)形結(jié)構(gòu)無(wú)限極輸出的方法
- ThinkPHP自動(dòng)填充實(shí)現(xiàn)無(wú)限級(jí)分類(lèi)的方法
- 使用ThinkPHP的自動(dòng)完成實(shí)現(xiàn)無(wú)限級(jí)分類(lèi)實(shí)例詳解
- Thinkphp無(wú)限級(jí)分類(lèi)代碼
- thinkPHP框架實(shí)現(xiàn)的無(wú)限回復(fù)評(píng)論功能示例
- thinkphp5實(shí)現(xiàn)無(wú)限級(jí)分類(lèi)
- PHP實(shí)現(xiàn)的無(wú)限分類(lèi)類(lèi)庫(kù)定義與用法示例【基于thinkPHP】
- thinkphp5使用無(wú)限極分類(lèi)
- TP5.0框架實(shí)現(xiàn)無(wú)限極回復(fù)功能的方法分析
相關(guān)文章
PHP數(shù)字前補(bǔ)0的自帶函數(shù)sprintf 和number_format的用法(詳解)
下面小編就為大家?guī)?lái)一篇PHP數(shù)字前補(bǔ)0的自帶函數(shù)sprintf 和number_format的用法(詳解)。小編覺(jué)得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2017-02-02
PHP+MySQL實(shí)現(xiàn)模糊查詢(xún)員工信息功能示例
這篇文章主要介紹了PHP+MySQL實(shí)現(xiàn)模糊查詢(xún)員工信息功能,結(jié)合實(shí)例形式分析了php連接mysql數(shù)據(jù)庫(kù)及使用like語(yǔ)句進(jìn)行模糊查詢(xún)與顯示相關(guān)操作技巧,需要的朋友可以參考下2018-06-06
講解WordPress中用于獲取評(píng)論模板和搜索表單的PHP函數(shù)
這篇文章主要介紹了WordPress中用于獲取評(píng)論模板和搜索表單的PHP函數(shù),需要的朋友可以參考下2015-12-12
PHP判斷是否是微信打開(kāi),瀏覽器打開(kāi)的方法
下面小編就為大家分享一篇PHP判斷是否是微信打開(kāi),瀏覽器打開(kāi)的方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2018-03-03
比較時(shí)間段一與時(shí)間段二是否有交集的php函數(shù)
PHP比較時(shí)間段一與時(shí)間段二是否有交集的實(shí)現(xiàn)代碼,需要的朋友可以參考下。2011-05-05
php lcg_value與mt_rand生成0~1隨機(jī)小數(shù)的效果對(duì)比分析
下面小編就為大家?guī)?lái)一篇php lcg_value與mt_rand生成0~1隨機(jī)小數(shù)的效果對(duì)比分析。小編覺(jué)得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2017-04-04
比較strtr, str_replace和preg_replace三個(gè)函數(shù)的效率
本篇文章是對(duì)strtr, str_replace和preg_replace三個(gè)函數(shù)的效率問(wèn)題進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下2013-06-06

