$mid) $rightArray[] = $v; //把比$mid大的数放到一个数组里 if($v < $mid) $leftArray[] = $v; //把比$mid小的数放到另一个数组里 } $leftArray = quickSort($leftArray); //把比较小的数组再一次进行分割 $leftArray[] = $mid; //把分割的元素加到小的数组后面,不能忘了它哦 $rightArray = quickSort($rightArray); //把比较大的数组再一次进行分割 return array_merge($leftArray,$rightArray); //组合两个结果 } // 获取Hashids 对象 function getHashids(){ global $hashids; if($hashids instanceof Hashids ){ return $hashids; } $hashids = new Hashids('D6M97LIvpp4qWuz3nKzqi6yYN4GAA61b',32); return $hashids; } /** * 获取对象或数组的属性值 * @param $param * @param $key * @param string $default * @return mixed|string */ function getProp($param, $key, $default = '') { $result = $default; if (is_object($param) && isset($param->$key)) { $result = $param->$key; } if (is_array($param) && isset($param[$key])) { $result = $param[$key]; } return $result; } /** * 获取真实IP */ function get_client_ip() { $ip = '0.0.0.0'; if ($request = request()) { $header = $request->header(); if(isset($header['remoteip'])){ $ip = $header['remoteip']; }else{ $rip = $request->getRealIp(); $riparr = explode(',',$rip); $ip = $riparr['0']; } } return $ip; } /** * 获取真实IP */ function get_client_ua() { $request = request(); $header = $request->header(); if(isset($header['user-agent'])){ return $header['user-agent']; } Logger::app('noagent:'.json_encode($header)); return ''; }