<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace ModStart\Core\Util; use Illuminate\Support\Str; class TagUtil { public static function seperated2Array($Cl9Wv, $T3BV1 = ',') { if (',' == $T3BV1) { $Cl9Wv = str_replace(array('，'), ',', $Cl9Wv); } return array_filter(explode(',', $Cl9Wv)); } public static function seperated2String($Cl9Wv, $T3BV1 = ',') { $ui8L2 = self::seperated2Array($Cl9Wv, $T3BV1); return self::array2String($ui8L2); } public static function array2String(array $Cl9Wv) { goto DTJAA; GeFst: return join('', array_unique($D_0M4)); goto PaZyI; Hv3hk: foreach ($Cl9Wv as &$xmeef) { goto cp7_Y; D1SwG: $D_0M4[] = ':' . $xmeef . ':'; goto bAbJ1; cp7_Y: $xmeef = trim($xmeef); goto Lbg9Q; Lbg9Q: if ($xmeef == '' || Str::contains($xmeef, ':')) { continue; } goto D1SwG; bAbJ1: } goto GeFst; DTJAA: $D_0M4 = array(); goto Hv3hk; PaZyI: } public static function string2Array($Cl9Wv, $KhkPS = 'auto') { goto hIZ9z; xPXn3: $Cl9Wv = explode('::', $Cl9Wv); goto Co_m2; n8GOs: foreach ($Cl9Wv as &$xmeef) { goto Z3ktB; eX6KV: if ($KhkPS == 'auto' && is_numeric($xmeef)) { $D_0M4[] = intval($xmeef); } else { $D_0M4[] = $xmeef; } goto B1R8t; Z3ktB: $xmeef = trim($xmeef); goto KoPqs; KoPqs: if (empty($xmeef)) { continue; } goto eX6KV; B1R8t: } goto ezgRv; ezgRv: return array_unique($D_0M4); goto cU6t7; Co_m2: $D_0M4 = array(); goto n8GOs; a7xVF: $Cl9Wv = trim($Cl9Wv, ':'); goto xPXn3; hIZ9z: if (is_array($Cl9Wv)) { $Cl9Wv = join('::', $Cl9Wv); if (!empty($Cl9Wv)) { $Cl9Wv = ":{$Cl9Wv}:"; } } goto a7xVF; cU6t7: } public static function recordsString2Array(&$bcEDt, $nisO_, $KhkPS = 'auto') { goto Fklnf; Fklnf: if (empty($bcEDt)) { return; } goto CRl8D; Ypljg: foreach ($bcEDt as &$tlo2Q) { foreach ($nisO_ as $jPfeB) { $tlo2Q[$jPfeB] = self::string2Array($tlo2Q[$jPfeB], $KhkPS); } } goto RVoFg; CRl8D: if (is_string($nisO_)) { $nisO_ = array($nisO_); } goto Ypljg; RVoFg: } public static function recordsArray2String(&$bcEDt, $nisO_) { goto XbxtR; yGA_y: foreach ($bcEDt as &$tlo2Q) { foreach ($nisO_ as $jPfeB) { $tlo2Q[$jPfeB] = self::array2String($tlo2Q[$jPfeB]); } } goto L1dw8; XbxtR: if (empty($bcEDt)) { return; } goto Mg1rI; Mg1rI: if (is_string($nisO_)) { $nisO_ = array($nisO_); } goto yGA_y; L1dw8: } public static function mapInfo($Cl9Wv, array $kNJap = array()) { foreach ($Cl9Wv as &$xmeef) { if (array_key_exists($xmeef, $kNJap)) { $xmeef = $kNJap[$xmeef]; } } return $Cl9Wv; } public static function map($Cl9Wv, array $kNJap = array()) { goto ejQnv; UvGdM: return $zI96O; goto z2nk_; ejQnv: if (is_string($Cl9Wv)) { $Cl9Wv = self::string2Array($Cl9Wv); } goto H0uHl; H0uHl: $zI96O = array(); goto jweul; jweul: foreach ($Cl9Wv as $xmeef) { if (array_key_exists($xmeef, $kNJap)) { $zI96O[$xmeef] = $kNJap[$xmeef]; } else { $zI96O[$xmeef] = null; } } goto UvGdM; z2nk_: } public static function urlJoin($m2Dmo, array $Cl9Wv, $P43za = null, $k_cy3 = 'number', $zn0KN = '_') { goto tqXDM; UdFMa: if ($m2Dmo) { $Cl9Wv = array_merge(array($m2Dmo), $Cl9Wv); } goto sTsTa; sTsTa: return join($zn0KN, $Cl9Wv); goto FbvKa; hWx9C: if ('number' == $k_cy3) { sort($Cl9Wv, SORT_NUMERIC); } else { sort($Cl9Wv, SORT_STRING); } goto UdFMa; tqXDM: if (null !== $P43za) { foreach ($Cl9Wv as $K_IJ6 => $xmeef) { if ($xmeef == $P43za) { unset($Cl9Wv[$K_IJ6]); } } } goto hWx9C; FbvKa: } }