无限极递归+树桩极结构
if(!function_exists('encrypt_password')){
function encrypt_password($password){
$salt = 'defggggd';
return md5($salt.md5($password));
}
}



if (!function_exists('get_cate_list')) {
//递归函数 实现无限级分类列表
function get_cate_list($list,$pid=0,$level=0) {
static $tree = array();
foreach($list as $row) {
if($row['pid']==$pid) {
$row['level'] = $level;
$tree[] = $row;
get_cate_list($list, $row['id'], $level + 1);
}
}
return $tree;
}
}
下拉页面渲染
        <select name="">
{volist name='list' id='v'}
<option value={$v.id}>
  {if condition="$v['level'] neq 0"}|{/if}
<?php echo str_repeat('-',$v['level']*8);?> 
{$v.cate_name}
{/volist}
</option>
</select>








if(!function_exists('get_tree_list')){
//引用方式实现 父子级树状结构
function get_tree_list($list){
//将每条数据中的id值作为其下标
$temp = [];
foreach($list as $v){
$v['son'] = [];
$temp[$v['id']] = $v;
}
//获取分类树
foreach($temp as $k=>$v){
$temp[$v['pid']]['son'][] = &$temp[$v['id']];
}
return isset($temp[0]['son']) ? $temp[0]['son'] : [];
}
}


图片上传+缩略图+水印
$file = request()->file('img');
//上传
$image = Image::open($file);
$path = md5(date('ymd his')).'.jpg';
$image->water('./thumb.png',Image::WATER_NORTHWEST)->save('./uploads'.$path);

$image = Image::open('./uploads'.$path);
$pash = md5(date('ymd his')).'.jpg';
$image->thumb(100,100)->save('./thumb/'.$pash);
posted on 2021-11-12 14:48  少雄3306  阅读(43)  评论(0)    收藏  举报