PHP常用工具類

2022-06-07 22:33:07 字數 4258 閱讀 5446

<?php

namespace isslib\util;

usethink\config;//

public

static

function getprefix(\(mprefix='')//

\(format_type_item=\)format_type[\(type];

//\)keys=array_keys(\(format_type_item);

//var_dump(\)format_type_item[\(keys[0]]);exit();

if(empty(\)number

))return self::getmaxunit(\(number,\)format_type_item,$extunit);/

////

////

///function letter(\(value)

\(value = intval(\)value / 26);

} while (\(temp != 0);

return

\)letter;}

////

//對excel裡的日期進行格式轉化/

function getdata(\(val)/

根據陣列中的某個鍵值大小進行排序,僅支援二維陣列

@param array $array 排序陣列

@param string $key 鍵值

@param bool $asc 預設正序

@return array 排序後陣列

/function arraysortbykey(array

\(array, \)key, \(asc = true

)

unset($v); //

對需要排序鍵值進行排序

$asc ? asort($values) : arsort($values); //

重新排列原有陣列

foreach ( $values

as$k => $v

)

$count=count($result

);

foreach ($result

as$key => $value

)

for ($i = 0; $i < $count; $i++)

$result =array_combine($iddata,$baifendata

);

return

$result

;

/*

* * 無限級分類,直接獲取節點樹

* @param unknown $list 資料集合

* @param string $pk 主鍵字段

* @param string $pid 父節點id對應字段

* @param string $child 子節點id對應字段

* @param number $root 從第幾級開始查詢

* @return multitype:unknown */

function list_to_tree($list, $pk='id',$pid = 'pid',$child = 'child',$root=0)

foreach ($list

as$key => $data

) else}}

}return

$tree;}

//無限極分類返回列表行記錄/**

* * @param unknown $cate_info_sort 返回的資料

* @param unknown $data 原始資料

* @param string $pk 表主鍵

* @param string $pid_name 表父字段id

* @param number $pid 開始的父欄位id

* @param string $kk 分割線 */

function cate_sort_role(&$cate_info_sort,$data,$pk='id',$pid_name="pid",$pid=0,$kk="|")

$cate_info_sort[$k]["kk"] = $kk

;

$pos = strpos($kk, "--");

if($pos === false

)else

cate_sort_role(

$cate_info_sort,$data ,$pk,$pid_name,$v[$pk],"    ".$kk."--");

}}}/

//function getmonth(\(sign="1")

else

}

<?php

namespace isslib\util;

usethink\config;

usethink\db;

usethink\debug;//

///\(format_type_item=\)format_type[\(type];

//\)keys=array_keys(\(format_type_item);

//var_dump(\)format_type_item[\(keys[0]]);exit();

if(empty(\)number

))return self::getmaxunit(\(number,\)format_type_item,$extunit);/

////

////

///public

static

function letter(\(value)

\(value = intval(\)value / 26);

} while (\(temp != 0);

return

\)letter;}

////

/public

static

function path_info(\(filepath,\)ds='/')//

/public

function checkmobile(\(mobilephone

) [0-9]\)|15[01236789][0-9]\(|18[01236789][0-9]\)/",\(mobilephone

)) else}/

////

public

static

function debug(\(str)/

//public

static

function get_grogress(\(start,\)end)/

<?php

namespace isslib\util;

usethink\config;

usethink\db;

usethink\debug;//

///\(format_type_item=\)format_type[\(type];

//\)keys=array_keys(\(format_type_item);

//var_dump(\)format_type_item[\(keys[0]]);exit();

if(empty(\)number

))return self::getmaxunit(\(number,\)format_type_item,$extunit);/

////

////

///public

static

function letter(\(value)

\(value = intval(\)value / 26);

} while (\(temp != 0);

return

\)letter;}

////

/public

static

function path_info(\(filepath,\)ds='/')//

/public

function checkmobile(\(mobilephone

) [0-9]\)|15[01236789][0-9]\(|18[01236789][0-9]\)/",\(mobilephone

)) else}/

////

public

static

function debug(\(str)/

//public

static

function get_grogress(\(start,\)end)/

常用工具類

本講內容 常用工具類 陸續更新 author administrator public static context context public void oncreate public static context getcontext 2 提供所有activity呼叫 基類 author ad...

常用工具類

reflectionutils objectutils public static void main string args 判斷兩個陣列是否相等 system.out.println arrays.equals arr,arr true 列印陣列 string s1 arrays.tostrin...

常用工具類 作業

1.生成10個 10,23 之間的隨機整數 random 類的nextdouble 或nextint 實現public class randomdemo for int i 1 i 10 i 1.以樹狀結構輸出計算機某個指定資料夾下的所有的檔案和子資料夾名稱。public class filedem...