<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace ModStart\Core\Util; use Illuminate\Support\Str; class TagUtil { public static function seperated2Array($UcFa2, $QCTxd = ',') { if (',' == $QCTxd) { $UcFa2 = str_replace(array('，'), ',', $UcFa2); } return array_filter(explode(',', $UcFa2)); } public static function seperated2String($UcFa2, $QCTxd = ',') { $Lydiv = self::seperated2Array($UcFa2, $QCTxd); return self::array2String($Lydiv); } public static function array2String(array $UcFa2) { goto kcz03; kcz03: $U4eJ8 = array(); goto sgqLu; sgqLu: foreach ($UcFa2 as &$DIfLH) { goto nG3PZ; pmdmi: if ($DIfLH == '' || Str::contains($DIfLH, ':')) { continue; } goto UWo8V; UWo8V: $U4eJ8[] = ':' . $DIfLH . ':'; goto dWNFq; nG3PZ: $DIfLH = trim($DIfLH); goto pmdmi; dWNFq: } goto jodgr; jodgr: return join('', array_unique($U4eJ8)); goto cb_Su; cb_Su: } public static function string2Array($UcFa2, $eQLzC = 'auto') { goto BJEVO; YN3nk: $U4eJ8 = array(); goto q0J6f; BJEVO: if (is_array($UcFa2)) { $UcFa2 = join('::', $UcFa2); if (!empty($UcFa2)) { $UcFa2 = ":{$UcFa2}:"; } } goto ShxWO; ldyW5: $UcFa2 = explode('::', $UcFa2); goto YN3nk; q0J6f: foreach ($UcFa2 as &$DIfLH) { goto sZyxH; sZyxH: $DIfLH = trim($DIfLH); goto weQj9; weQj9: if (empty($DIfLH)) { continue; } goto XApWC; XApWC: if ($eQLzC == 'auto' && is_numeric($DIfLH)) { $U4eJ8[] = intval($DIfLH); } else { $U4eJ8[] = $DIfLH; } goto h4_iO; h4_iO: } goto Twxjc; Twxjc: return array_unique($U4eJ8); goto lPbnP; ShxWO: $UcFa2 = trim($UcFa2, ':'); goto ldyW5; lPbnP: } public static function recordsString2Array(&$feJuE, $nilYY, $eQLzC = 'auto') { goto KUGLV; IaCVC: if (is_string($nilYY)) { $nilYY = array($nilYY); } goto L_qOo; KUGLV: if (empty($feJuE)) { return; } goto IaCVC; L_qOo: foreach ($feJuE as &$Jd1Wg) { foreach ($nilYY as $rvTrU) { $Jd1Wg[$rvTrU] = self::string2Array($Jd1Wg[$rvTrU], $eQLzC); } } goto Wyhql; Wyhql: } public static function recordsArray2String(&$feJuE, $nilYY) { goto WfeVo; WfeVo: if (empty($feJuE)) { return; } goto amf9G; amf9G: if (is_string($nilYY)) { $nilYY = array($nilYY); } goto pMiKk; pMiKk: foreach ($feJuE as &$Jd1Wg) { foreach ($nilYY as $rvTrU) { $Jd1Wg[$rvTrU] = self::array2String($Jd1Wg[$rvTrU]); } } goto i_ega; i_ega: } public static function mapInfo($UcFa2, array $BF0fV = array()) { foreach ($UcFa2 as &$DIfLH) { if (array_key_exists($DIfLH, $BF0fV)) { $DIfLH = $BF0fV[$DIfLH]; } } return $UcFa2; } public static function map($UcFa2, array $BF0fV = array()) { goto P5ytV; HY4_N: foreach ($UcFa2 as $DIfLH) { if (array_key_exists($DIfLH, $BF0fV)) { $ozCYZ[$DIfLH] = $BF0fV[$DIfLH]; } else { $ozCYZ[$DIfLH] = null; } } goto eNGQ4; eNGQ4: return $ozCYZ; goto qqMxf; iuZhM: $ozCYZ = array(); goto HY4_N; P5ytV: if (is_string($UcFa2)) { $UcFa2 = self::string2Array($UcFa2); } goto iuZhM; qqMxf: } public static function urlJoin($YjgEW, array $UcFa2, $MugqV = null, $UHuVA = 'number', $pGdzc = '_') { goto e4nSv; e4nSv: if (null !== $MugqV) { foreach ($UcFa2 as $R80S9 => $DIfLH) { if ($DIfLH == $MugqV) { unset($UcFa2[$R80S9]); } } } goto lSLhq; lSLhq: if ('number' == $UHuVA) { sort($UcFa2, SORT_NUMERIC); } else { sort($UcFa2, SORT_STRING); } goto i5EBo; i5EBo: if ($YjgEW) { $UcFa2 = array_merge(array($YjgEW), $UcFa2); } goto rTSjP; rTSjP: return join($pGdzc, $UcFa2); goto Amvuf; Amvuf: } }