0) { for ($i = 0; $i < $iteration; $i++) { $encoded = hash($algo, $encoded, true); } } $tmp = unpack('H*', $encoded); if (!empty($tmp) && !empty($tmp[1])) { $res = $tmp[1]; } return $res; } /** * 检查权限 * @param type $url * @param type $old_url * @return type */ function chkCommission($url, $old_url) { return app\common\api\MenuApi::chkPermission($url, $old_url); } /** * 随机字符ID * @return type */ function getStringId() { $day = random_int(10, 30); $time = strtotime("-4 years -6 months -" . $day . " days"); $randnum = random_int(100000000, 999999999); $randnum = str_shuffle($randnum); return $time . $randnum; } function isNullOrEmpty($obj) { if (!$obj || $obj == "" || !isset($obj)) return ""; return $obj; } function getTreeList($array, $id_field = "id", $pid_field = "pid", $value = "0") { static $result = []; foreach ($array as $key => $item) { if ($value == $item[$pid_field]) { $result[] = $item; unset($array[$key]); getTreeList($array, $id_field, $pid_field, $item[$id_field]); } } return $result; }