common.php 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548
  1. <?php
  2. // 应用公共文件
  3. /**
  4. *
  5. * @param type $algo
  6. * @param type $password
  7. * @param type $salt
  8. * @param type $hash_iterations
  9. * @return type
  10. */
  11. function simple_hash($algo = 'md5', $password = '', $salt = '', $hash_iterations = 2) {
  12. $res = '';
  13. $pass = $salt . $password;
  14. $encoded = hash($algo, $pass, true);
  15. $iteration = $hash_iterations - 1;
  16. if ($iteration > 0) {
  17. for ($i = 0; $i < $iteration; $i++) {
  18. $encoded = hash($algo, $encoded, true);
  19. }
  20. }
  21. $tmp = unpack('H*', $encoded);
  22. if (!empty($tmp) && !empty($tmp[1])) {
  23. $res = $tmp[1];
  24. }
  25. return $res;
  26. }
  27. /**
  28. * 检查权限
  29. * @param type $url
  30. * @param type $old_url
  31. * @return type
  32. */
  33. function chkCommission($url, $old_url) {
  34. return app\common\api\MenuApi::chkPermission($url, $old_url);
  35. }
  36. /**
  37. * 随机字符ID
  38. * @return type
  39. */
  40. function getStringId() {
  41. $day = random_int(10, 30);
  42. $time = strtotime("-4 years -6 months -" . $day . " days");
  43. $randnum = random_int(100000000, 999999999);
  44. $randnum = str_shuffle($randnum);
  45. return $time . $randnum;
  46. }
  47. function isNullOrEmpty($obj) {
  48. if (!$obj || $obj == "" || !isset($obj))
  49. return "";
  50. return $obj;
  51. }
  52. function getTreeList($array, $id_field = "id", $pid_field = "pid", $value = "0") {
  53. static $result = [];
  54. foreach ($array as $key => $item) {
  55. if ($value == $item[$pid_field]) {
  56. $result[] = $item;
  57. unset($array[$key]);
  58. getTreeList($array, $id_field, $pid_field, $item[$id_field]);
  59. }
  60. }
  61. return $result;
  62. }
  63. /**
  64. * 读取excel
  65. * @param type $filepath
  66. * @param type $sheetIndex
  67. * @return type
  68. */
  69. function getExcelDatas($filepath, $sheetIndex = 0) {
  70. $spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($filepath);
  71. $sheet = $spreadsheet->getSheet($sheetIndex);
  72. /* $reader_type = \PHPExcel_IOFactory::identify($filepath);
  73. $reader = \PHPExcel_IOFactory::createReader($reader_type);
  74. $phpexcel = $reader->load($filepath);
  75. $sheet = $phpexcel->getSheet($sheetIndex); */
  76. return $sheet->toArray();
  77. }
  78. /**
  79. * 导出excel
  80. * @param type $columns 列标题
  81. * @param type $rows 内容
  82. * @param string $filename 文件名
  83. * @param string $settings 样式批设置
  84. * @param type $sheetname sheet标题
  85. * @param type $saveurl 保存位置
  86. * @param type $author 作者
  87. */
  88. function export($columns, $rows, $filename = "jjrcw", $settings = [], $sheetname = "sheet1", $saveurl = "php://output", $author = "晋江人才网") {
  89. $datatype = new \PhpOffice\PhpSpreadsheet\Cell\DataType;
  90. $spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
  91. $spreadsheet->getProperties()->setCreator($author)
  92. ->setLastModifiedBy($author)
  93. ->setTitle($filename)
  94. ->setSubject($filename);
  95. $spreadsheet->setActiveSheetIndex(0);
  96. $objPHPExcel = $spreadsheet->getActiveSheet();
  97. $objPHPExcel->setTitle($sheetname);
  98. $filename .= "_" . time();
  99. $titleStartLine = 1;
  100. $rowStartLine = $titleStartLine + 1;
  101. $colCount = count($columns);
  102. $rowCount = count($rows);
  103. //设置表头
  104. for ($i = 0; $i < $colCount; $i++) {
  105. $objPHPExcel->setCellValue(getExcelColumnByIndex($i) . $titleStartLine, $columns[$i]);
  106. }
  107. //设置正文内容
  108. for ($i = 0; $i < $rowCount; $i++) {
  109. for ($n = 0; $n < $colCount; $n++) {
  110. if (is_numeric($rows[$i][$n]) && strlen($rows[$i][$n]) > 17) {
  111. //超过17位的数字转成文本方以免被转化为科学数
  112. $objPHPExcel->setCellValueExplicit(getExcelColumnByIndex($n) . ($rowStartLine + $i), $rows[$i][$n], $datatype::TYPE_STRING);
  113. } else {
  114. $objPHPExcel->setCellValue(getExcelColumnByIndex($n) . ($rowStartLine + $i), $rows[$i][$n]);
  115. }
  116. }
  117. }
  118. $objPHPExcel->getDefaultColumnDimension()->setWidth(16); //默认列宽
  119. $objPHPExcel->getDefaultRowDimension()->setRowHeight(30); //默认列高
  120. //样式设置
  121. $settings = $settings ?: getCommonExcelSetting($colCount, $rowCount);
  122. foreach ($settings as $type => $cfg) {
  123. switch ($type) {
  124. case "width":
  125. for ($i = 0; $i < count($cfg); $i++) {
  126. $objPHPExcel->getColumnDimension($cfg[$i][0])->setWidth($cfg[$i][1]);
  127. }
  128. break;
  129. case "height":
  130. for ($i = 0; $i < count($cfg); $i++) {
  131. $objPHPExcel->getRowDimension($cfg[$i][0])->setRowHeight($cfg[$i][1]);
  132. }
  133. break;
  134. case "background-color":
  135. for ($i = 0; $i < count($cfg); $i++) {
  136. $objPHPExcel->getStyle($cfg[$i][0])->getFill()->setFillType(PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID)->getStartColor($cfg[$i][1])->setARGB($cfg[$i][1]);
  137. }
  138. break;
  139. case "border":
  140. $objPHPExcel->getStyle($cfg)->applyFromArray(array(
  141. "borders" => array(
  142. "allBorders" => array(
  143. 'borderStyle' => PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN
  144. )
  145. )
  146. ));
  147. break;
  148. case "align":
  149. for ($i = 0; $i < count($cfg); $i++) {
  150. switch ($cfg[$i][1]) {
  151. case "left":
  152. $hAlign = PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_LEFT;
  153. break;
  154. case "right":
  155. $hAlign = PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_RIGHT;
  156. break;
  157. case "hCenter":
  158. $hAlign = PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER;
  159. break;
  160. case "hJustify":
  161. $hAlign = PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_JUSTIFY;
  162. break;
  163. case "top":
  164. $vAlign = PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_TOP;
  165. break;
  166. case "bottom":
  167. $vAlign = PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_BOTTOM;
  168. break;
  169. case "vCenter":
  170. $vAlign = PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_CENTER;
  171. break;
  172. case "vJustify":
  173. $vAlign = PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_JUSTIFY;
  174. break;
  175. }
  176. $align = [];
  177. if ($hAlign) {
  178. $align["horizontal"] = $hAlign;
  179. }
  180. if ($vAlign) {
  181. $align["vertical"] = $vAlign;
  182. }
  183. $objPHPExcel->getStyle($cfg[$i][0])->applyFromArray([
  184. "alignment" => $align
  185. ]);
  186. }
  187. break;
  188. case "color":
  189. for ($i = 0; $i < count($cfg); $i++) {
  190. $objPHPExcel->getStyle($cfg[$i][0])->getFont()->getColor()->setARGB($cfg[$i][1]);
  191. }
  192. break;
  193. case "wrap":
  194. for ($i = 0; $i < count($cfg); $i++) {
  195. $objPHPExcel->getStyle($cfg[$i])->getAlignment()->setWrapText(true); //cellvalue包含\n设为自动换行
  196. }
  197. break;
  198. }
  199. }
  200. header('Content-Type: application/vnd.ms-excel');
  201. header('Content-Disposition: attachment;filename="' . $filename . '.xls"');
  202. $writer = new \PhpOffice\PhpSpreadsheet\Writer\Xls($spreadsheet);
  203. $writer->save($saveurl);
  204. //删除临时的sheet
  205. $spreadsheet->disconnectWorksheets();
  206. unset($spreadsheet);
  207. exit;
  208. }
  209. /**
  210. * 根据传入的数值(游标),从26个英文字母的数组中查询,返回excel列标
  211. * @param int $index 游标从0开始
  212. * @return string 返回列标
  213. */
  214. function getExcelColumnByIndex(int $index) {
  215. $letters = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z');
  216. if ($letters[$index])
  217. return $letters[$index];
  218. $rowIndex = floor($index / 26) - 1;
  219. $colIndex = $index % 26;
  220. return $letters[$rowIndex] . $letters[$colIndex];
  221. }
  222. /**
  223. * 公共的excel设置
  224. * @return type
  225. */
  226. function getCommonExcelSetting($columns, $rows) {
  227. return $settings = [
  228. "background-color" => [[sprintf("A1:%s1", getExcelColumnByIndex($columns - 1)), "0066CC"]],
  229. "color" => [[sprintf("A1:%s1", getExcelColumnByIndex($columns - 1)), "FFFFFF"]],
  230. "border" => sprintf("A1:%s%d", getExcelColumnByIndex($columns - 1), $rows + 1),
  231. "wrap" => [sprintf("A2:%s%d", getExcelColumnByIndex($columns - 1), $rows + 1)],
  232. "align" => [[sprintf("A1:%s%d", getExcelColumnByIndex($columns - 1), $rows + 1), "hCenter"], [sprintf("A1:%s%d", getExcelColumnByIndex($columns - 1), $rows + 1), "vCenter"]]
  233. ];
  234. }
  235. /**
  236. * 检查是不是excel格式,不确定是否都是可用文件,主要还是第一和最后一个比较常见
  237. * @param type $mime
  238. * @return type
  239. */
  240. function isExcelFile($mime) {
  241. return in_array($mime, [
  242. "application/vnd.ms-excel",
  243. "application/msexcel",
  244. "application/x-msexcel",
  245. "application/x-ms-excel",
  246. "application/x-excel",
  247. "application/x-dos_ms_excel",
  248. "application/xls",
  249. "application/x-xls",
  250. "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
  251. ]);
  252. }
  253. /**
  254. * 获取主机名带协议
  255. * @return http[s]://xxxx
  256. */
  257. function getHostWithProtocol() {
  258. $protocol = (strpos(strtolower($_SERVER['SERVER_PROTOCOL']), 'http/2.0') !== false || $_SERVER["HTTPS"] == "on" || $_SERVER["REQUEST_SCHEME"] == "https" ? 'https' : 'http') . "://";
  259. return $protocol . $_SERVER["HTTP_HOST"];
  260. }
  261. /**
  262. * 获得上传文件的路径
  263. * @param $path
  264. * @param $stillOriginalPath 如果是pdf这类文件会生成fileview格式的url,此参数为真是则生成原始url
  265. * @return string
  266. */
  267. function getStoragePath($path, $stillOriginalPath = false) {
  268. if (!$path)
  269. return "";
  270. if (strpos($path, "jjrcw") === 0) {
  271. $path = "https://rc.jucai.gov.cn/ftp/{$path}";
  272. } else {
  273. $path = getHostWithProtocol() . "/storage/{$path}";
  274. }
  275. if (isImage($path) || $stillOriginalPath)
  276. return $path;
  277. return getFileView($path);
  278. }
  279. function getFileView($path) {
  280. return $path;
  281. //$complete_path = "https://report.jinjianghc.com/" . getStoragePath($path);
  282. return "https://fileview.jinjianghc.com/onlinePreview?url=" . base64_encode($path) . "&officePreviewType=pdf";
  283. }
  284. function isImage($filename) {
  285. $types = '.gif|.jpeg|.png|.bmp'; //定义检查的图片类型
  286. try {
  287. $info = getimagesize($filename);
  288. if ($info && stripos($types, image_type_to_extension($info['2'])) !== false) {
  289. return true;
  290. }
  291. return false;
  292. } catch (\think\exception $e) {
  293. //文件不存在,根据拓展名返回
  294. $types = "gif|jpg|jpeg|png|bmp";
  295. $pathinfo = pathinfo($filename);
  296. $ext = $pathinfo["extension"];
  297. if ($pathinfo && $ext && stripos($types, $ext) !== false) {
  298. return true;
  299. }
  300. return false;
  301. }
  302. }
  303. function chkEnterpriseFull($ep) {
  304. switch ($ep->special) {
  305. case 0:
  306. if ($ep["type"] == 1) {
  307. $checkEnterpriseFullFields = ["agencyType", "enterpriseTag", "enterpriseType", "bankCard", "bankNetwork", "bank", "imgurl", "bankImg", "beian"];
  308. if ($ep["agencyType"] == 1) {
  309. $checkEnterpriseFullFields[] = "industryFieldNew";
  310. $checkEnterpriseFullFields[] = "industryFieldOld";
  311. $checkEnterpriseFullFields[] = "domainImg";
  312. }
  313. if (in_array($ep["enterpriseType"], ['guishang', 'gaoxinjishu', 'zhuanjingtexin'])) {
  314. $checkEnterpriseFullFields[] = "typeImg";
  315. }
  316. } else {
  317. $checkEnterpriseFullFields = ["bankCard", "bankNetwork", "bank", "imgurl", "bankImg", "beian"];
  318. }
  319. break;
  320. case 1:
  321. $checkEnterpriseFullFields = ["institutionTag"];
  322. break;
  323. case 3:
  324. $checkEnterpriseFullFields = ["organizationTag"];
  325. break;
  326. }
  327. $errorCounts = 0;
  328. while ($chk = array_shift($checkEnterpriseFullFields)) {
  329. if ($ep[$chk] == null)
  330. $errorCounts++;
  331. }
  332. if ($errorCounts > 0) {
  333. echo sprintf("<script>"
  334. . "parent.layer.confirm('系统升级,您的资料需要同步更新,请移步机构用户中心进行修改【机构信息变更】。',"
  335. . "function(){"
  336. . "var url='/enterprise/index/centerPage';"
  337. . "top.$('a.J_menuItem[href=\"'+url+'\"]').click();clkTab();"
  338. . "},function(){parent.layer.closeAll();});function clkTab(){setTimeout(function(){if(top.$('iframe.J_iframe[data-id=\"/enterprise/index/centerPage\"]').contents().find('a[href=\"#tab-2\"]').length==1){"
  339. . "top.$('iframe.J_iframe[data-id=\"/enterprise/index/centerPage\"]').contents().find('*.active').removeClass('active');"
  340. . "top.$('iframe.J_iframe[data-id=\"/enterprise/index/centerPage\"]').contents().find('ul.nav-tabs li').eq(1).addClass('active');"
  341. . "top.$('iframe.J_iframe[data-id=\"/enterprise/index/centerPage\"]').contents().find('#tab-2').addClass('active');parent.layer.closeAll();"
  342. . "}else{clkTab();}},20);};"
  343. . "</script>");
  344. return false;
  345. }
  346. return true;
  347. }
  348. function generate_password($length = 8) {
  349. $chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%&*?';
  350. $password = '';
  351. for ($i = 0; $i < $length; $i++) {
  352. // 这里提供两种字符获取方式
  353. // 第一种是使用 substr 截取$chars中的任意一位字符;
  354. // 第二种是取字符数组 $chars 的任意元素
  355. // $password .= substr($chars, mt_rand(0, strlen($chars) – 1), 1);
  356. $password .= $chars[mt_rand(0, strlen($chars) - 1)];
  357. }
  358. return $password;
  359. }
  360. /**
  361. * 判断是否为合法的身份证号码
  362. * @param $mobile
  363. * @return int
  364. */
  365. function isCreditNo($vStr) {
  366. $vCity = array(
  367. '11', '12', '13', '14', '15', '21', '22',
  368. '23', '31', '32', '33', '34', '35', '36',
  369. '37', '41', '42', '43', '44', '45', '46',
  370. '50', '51', '52', '53', '54', '61', '62',
  371. '63', '64', '65', '71', '81', '82', '91'
  372. );
  373. if (!preg_match('/^([\d]{17}[xX\d]|[\d]{15})$/', $vStr))
  374. return false;
  375. if (!in_array(substr($vStr, 0, 2), $vCity))
  376. return false;
  377. $vStr = preg_replace('/[xX]$/i', 'a', $vStr);
  378. $vLength = strlen($vStr);
  379. if ($vLength == 18) {
  380. $vBirthday = substr($vStr, 6, 4) . '-' . substr($vStr, 10, 2) . '-' . substr($vStr, 12, 2);
  381. } else {
  382. $vBirthday = '19' . substr($vStr, 6, 2) . '-' . substr($vStr, 8, 2) . '-' . substr($vStr, 10, 2);
  383. }
  384. if (date('Y-m-d', strtotime($vBirthday)) != $vBirthday)
  385. return false;
  386. if ($vLength == 18) {
  387. $vSum = 0;
  388. for ($i = 17; $i >= 0; $i--) {
  389. $vSubStr = substr($vStr, 17 - $i, 1);
  390. $vSum += (pow(2, $i) % 11) * (($vSubStr == 'a') ? 10 : intval($vSubStr, 11));
  391. }
  392. if ($vSum % 11 != 1)
  393. return false;
  394. }
  395. return true;
  396. }
  397. function get_client_ip() {
  398. $forwarded = request()->header("x-forwarded-for");
  399. if ($forwarded) {
  400. $ip = explode(',', $forwarded)[0];
  401. } else {
  402. $ip = request()->ip();
  403. }
  404. return $ip;
  405. }
  406. /**
  407. * 通过CURL发送HTTP请求
  408. * @param string $url //请求URL
  409. * @param array $postFields //请求参数
  410. * @return mixed
  411. *
  412. */
  413. function curlPost($url, $postFields) {
  414. $postFields = json_encode($postFields);
  415. $ch = curl_init();
  416. curl_setopt($ch, CURLOPT_URL, $url);
  417. curl_setopt($ch, CURLOPT_HTTPHEADER, array(
  418. 'Content-Type: application/json; charset=utf-8' //json版本需要填写 Content-Type: application/json;
  419. )
  420. );
  421. curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); //若果报错 name lookup timed out 报错时添加这一行代码
  422. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  423. curl_setopt($ch, CURLOPT_POST, 1);
  424. curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields);
  425. curl_setopt($ch, CURLOPT_TIMEOUT, 60);
  426. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
  427. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  428. $ret = curl_exec($ch);
  429. if (false == $ret) {
  430. $result = curl_error($ch);
  431. } else {
  432. $rsp = curl_getinfo($ch, CURLINFO_HTTP_CODE);
  433. if (200 != $rsp) {
  434. $result = "请求状态 " . $rsp . " " . curl_error($ch);
  435. } else {
  436. $result = $ret;
  437. }
  438. }
  439. curl_close($ch);
  440. return $result;
  441. }
  442. function getCacheById($key, $field, $fieldKey = null) {
  443. $redis = \app\common\Redis::instance(think\facade\Config::get("cache.stores.redis.select"));
  444. $info = $redis->hGet($key, $field);
  445. $result = json_decode($info, true);
  446. if ($fieldKey)
  447. return $result[$fieldKey];
  448. return $result;
  449. }
  450. function getJsonConfig($filepath, $field) {
  451. if (file_exists($filepath)) {
  452. return json_decode(file_get_contents($filepath), true)[$field];
  453. }
  454. return null;
  455. }
  456. //加密前补齐
  457. function mystr_pad($data,$len = 16){
  458. $n = $len - strlen($data) % $len;
  459. $data = $data . str_repeat(chr($n), $n);
  460. return $data;
  461. }
  462. // 解密后去掉补齐
  463. function mystr_unpad($data){
  464. $n = ord(substr($data,-1));
  465. return substr($data, 0, -$n);
  466. }
  467. //计算两个日期的时间差
  468. function diffDate($date1,$date2){
  469. if (strtotime($date1) > strtotime($date2)) {
  470. $ymd = $date2;
  471. $date2 = $date1;
  472. $date1 = $ymd;
  473. }
  474. $date1 = date('Y-m-d',strtotime($date1));
  475. $date2 = date('Y-m-d',strtotime($date2));
  476. list($y1, $m1, $d1) = explode('-', $date1);
  477. list($y2, $m2, $d2) = explode('-', $date2);
  478. $y = $m = $d = $_m = 0;
  479. $math = ($y2 - $y1) * 12 + $m2 - $m1;
  480. $y = intval(floor($math / 12));
  481. $m = intval($math % 12);
  482. $d = (mktime(0, 0, 0, $m2, $d2, $y2) - mktime(0, 0, 0, $m2, $d1, $y2)) / 86400;
  483. if ($d < 0) {
  484. $m -= 1;
  485. $d += date('j', mktime(0, 0, 0, $m2, 0, $y2));
  486. }
  487. return array($y, $m, $d);
  488. }
  489. function formatDateByMonth($date1,$date2,$data = []){
  490. if (strtotime($date1) > strtotime($date2)) {
  491. $ymd = $date2;
  492. $date2 = $date1;
  493. $date1 = $ymd;
  494. }
  495. $sTime = strtotime(date('Y-m-01', strtotime($date1)));
  496. $eTime = strtotime(date('Y-m-01', strtotime($date2)));
  497. $month_arr = [];
  498. for($sTime; $sTime <= $eTime; $sTime = strtotime('+1 month', $sTime)){
  499. $month_arr[date('Ym',$sTime)] = date('Y-m',$sTime); // 取得递增月;
  500. }
  501. if(is_array($data) && count($data) > 0){
  502. foreach ($data as $item) {
  503. if(array_key_exists($item['aae003'],$month_arr)){
  504. $month_arr[$item['aae003']] .= "<span style='color:green'>已缴费</span>";
  505. }
  506. }
  507. }
  508. return $month_arr;
  509. }
  510. function proSearch($str,$arr){
  511. $match_res = [];
  512. array_filter($arr,function($arr) use ($str,&$match_res){
  513. if(stripos($arr['value'],$str) !== false){
  514. $match_res[] = $arr['value'];
  515. return true;
  516. }else{
  517. return false;
  518. }
  519. });
  520. }