php代码
Magento是一套专业开源的PHP电子商务系统。Magento设计得非常灵活,具有模块化架构体系和丰富的功能。易于与第三方应用系统无缝集成。Magento开源网店系统的特点主要分以下几大类,网站管理促销和工具国际化支持SEO搜索引擎优化结账方式运输快递支付方式客户服务用户帐户目录管理目录浏览产品展示分析和报表Magento 1.6 主要包含以下新特性:•持久性购物 - 为不同的
0
<?php
class TestControl extends Control{
private $temp = array(
array("id"=>3,"name"=>"小说","pid"=>1),
array("id"=>4,"name"=>"足球","pid"=>2),
array("id"=>1,"name"=>"书","pid"=>0),
array("id"=>2,"name"=>"球","pid"=>0),
array("id"=>5,"name"=>"陶瓷","pid"=>0),
array("id"=>6,"name"=>"言情小说","pid"=>3)
);
public function __construct(){
parent::__construct();
}
public function recursion(){
$ret = $this->recursionArray($this->temp,0);
$html = $this->cHtml($ret);
echo $html;
}
public function recursionArray($arr,$pid){
$tree = '';
foreach ($arr as $key=>$value){
if($value['pid'] == $pid){
$value['pid'] = $this->recursionArray($arr,$value['id']);
$tree[] = $value;
}
}
return $tree;
}
public function cHtml($arr){
// $html = "";
// foreach ($arr as $key=>$value){
// if($value['pid'] == $pid){
// $html .= "<ul>";
// $html .= "<li class=''>".$value['name'];
// $html .= $this->cHtml($arr,$value['id']);
// $html .= "</li>";
// $html .= "</ul>";
// }
// }
// return $html;
$html = "";
$html .= "<ul>";
foreach ($arr as $key=>$value){
if(is_array($value['pid'])){
$html .="<li class='main'>".$value['name'];
$html .= $this->cHtml($value['pid']);
}else {
$html .="<li class=''>".$value['name'];
}
$html .= "</li>";
}
$html .= "</ul>";
return $html;
}
}
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号