<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace ModStart\Core\Util; use Illuminate\Support\Str; class TagUtil { public static function seperated2Array($l7oqU, $MPsPN = ',') { if (',' == $MPsPN) { $l7oqU = str_replace(array('，'), ',', $l7oqU); } return array_filter(explode(',', $l7oqU)); } public static function seperated2String($l7oqU, $MPsPN = ',') { $SEvvy = self::seperated2Array($l7oqU, $MPsPN); return self::array2String($SEvvy); } public static function array2String(array $l7oqU) { goto aiAAd; EIeTG: foreach ($l7oqU as &$y4wLA) { goto pbc0l; XSQf1: $s6jAF[] = ':' . $y4wLA . ':'; goto qK6AE; pbc0l: $y4wLA = trim($y4wLA); goto QJ6U5; QJ6U5: if ($y4wLA == '' || Str::contains($y4wLA, ':')) { continue; } goto XSQf1; qK6AE: } goto S0KmM; aiAAd: $s6jAF = array(); goto EIeTG; S0KmM: return join('', array_unique($s6jAF)); goto RzFgx; RzFgx: } public static function string2Array($l7oqU, $i1uhm = 'auto') { goto fimqC; B5Yyy: foreach ($l7oqU as &$y4wLA) { goto UZXos; UZXos: $y4wLA = trim($y4wLA); goto EZ7IW; x4dKW: if ($i1uhm == 'auto' && is_numeric($y4wLA)) { $s6jAF[] = intval($y4wLA); } else { $s6jAF[] = $y4wLA; } goto KrklM; EZ7IW: if (empty($y4wLA)) { continue; } goto x4dKW; KrklM: } goto RlDHL; ItC2j: $s6jAF = array(); goto B5Yyy; fimqC: if (is_array($l7oqU)) { $l7oqU = join('::', $l7oqU); if (!empty($l7oqU)) { $l7oqU = ":{$l7oqU}:"; } } goto orrZL; orrZL: $l7oqU = trim($l7oqU, ':'); goto smVMv; smVMv: $l7oqU = explode('::', $l7oqU); goto ItC2j; RlDHL: return array_unique($s6jAF); goto KLSm5; KLSm5: } public static function recordsString2Array(&$lz_pk, $cMru3, $i1uhm = 'auto') { goto MaCxc; MaCxc: if (empty($lz_pk)) { return; } goto cloc4; VI1vy: foreach ($lz_pk as &$kwA4W) { foreach ($cMru3 as $VFU9l) { $kwA4W[$VFU9l] = self::string2Array($kwA4W[$VFU9l], $i1uhm); } } goto lrYl_; cloc4: if (is_string($cMru3)) { $cMru3 = array($cMru3); } goto VI1vy; lrYl_: } public static function recordsArray2String(&$lz_pk, $cMru3) { goto Uh3mv; AD0D2: foreach ($lz_pk as &$kwA4W) { foreach ($cMru3 as $VFU9l) { $kwA4W[$VFU9l] = self::array2String($kwA4W[$VFU9l]); } } goto V0TqO; m2mE7: if (is_string($cMru3)) { $cMru3 = array($cMru3); } goto AD0D2; Uh3mv: if (empty($lz_pk)) { return; } goto m2mE7; V0TqO: } public static function mapInfo($l7oqU, array $FEPtU = array()) { foreach ($l7oqU as &$y4wLA) { if (array_key_exists($y4wLA, $FEPtU)) { $y4wLA = $FEPtU[$y4wLA]; } } return $l7oqU; } public static function map($l7oqU, array $FEPtU = array()) { goto QFD8X; slzBp: $OQrR1 = array(); goto hxtg3; hxtg3: foreach ($l7oqU as $y4wLA) { if (array_key_exists($y4wLA, $FEPtU)) { $OQrR1[$y4wLA] = $FEPtU[$y4wLA]; } else { $OQrR1[$y4wLA] = null; } } goto tkAfu; QFD8X: if (is_string($l7oqU)) { $l7oqU = self::string2Array($l7oqU); } goto slzBp; tkAfu: return $OQrR1; goto EXHWg; EXHWg: } public static function urlJoin($tpgiq, array $l7oqU, $LG4Qq = null, $dwufv = 'number', $btkk_ = '_') { goto uYn0h; JX_Rh: if ($tpgiq) { $l7oqU = array_merge(array($tpgiq), $l7oqU); } goto ptKmJ; uYn0h: if (null !== $LG4Qq) { foreach ($l7oqU as $xlsSz => $y4wLA) { if ($y4wLA == $LG4Qq) { unset($l7oqU[$xlsSz]); } } } goto xuJIA; xuJIA: if ('number' == $dwufv) { sort($l7oqU, SORT_NUMERIC); } else { sort($l7oqU, SORT_STRING); } goto JX_Rh; ptKmJ: return join($btkk_, $l7oqU); goto eL3O1; eL3O1: } }