Skip to content

Latest commit

 

History

History
91 lines (54 loc) · 1.89 KB

Public-Method.md

File metadata and controls

91 lines (54 loc) · 1.89 KB

Public-Method

常用方法

//+------------------------------------------------------

explode(',', $res)将字符串转换成一维数组

//+------------------------------------------------------

//+------------------------------------------------------

implode(',', $res)将一维数组转换成字符串

//+------------------------------------------------------

//+------------------------------------------------------

array_filter($res)过滤空的一维数组

//+------------------------------------------------------

//+------------------------------------------------------

array_values($res)重置键名

//+------------------------------------------------------

//+------------------------------------------------------

//将一维数组转换成二维数组

$test_three = array();

foreach ($test_two as $k => $v) {

$test_three[] = array('img' => $v);

}

//+------------------------------------------------------

//+-------------------------------------------------------

//二维数组转一维

$user_array = array();

foreach ($user as $k => $v) {

 $user_array[] = $v['id'];

}

//+-------------------------------------------------------

//+--------------------------------------------------------

unset($user[$k]);//抛出数组中不需要的

//+--------------------------------------------------------

/**

  • 获取PDF的页数 */

function getPageTotal($path){ // 打开文件 if (!$fp = @fopen($path,"r")) { $error = "打开文件{$path}失败"; return false; } else { $max=0; while(!feof($fp)) { $line = fgets($fp,255); if (preg_match('//Count [0-9]+/', $line, $matches)){ preg_match('/[0-9]+/',$matches[0], $matches2); if ($max<$matches2[0]) $max=$matches2[0]; } } fclose($fp); // 返回页数 return $max; } }