<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace ModStart\Core\Util; use Illuminate\Support\Str; class TagUtil { public static function seperated2Array($igZ39, $uB4FA = ',') { if (',' == $uB4FA) { $igZ39 = str_replace(array('，'), ',', $igZ39); } return array_filter(explode(',', $igZ39)); } public static function seperated2String($igZ39, $uB4FA = ',') { $en0Zs = self::seperated2Array($igZ39, $uB4FA); return self::array2String($en0Zs); } public static function array2String(array $igZ39) { goto Z47oy; yVZyK: foreach ($igZ39 as &$aV0xo) { goto kayEO; kayEO: $aV0xo = trim($aV0xo); goto AeSQy; hqWr2: $T63Lv[] = ':' . $aV0xo . ':'; goto vPZGl; AeSQy: if ($aV0xo == '' || Str::contains($aV0xo, ':')) { continue; } goto hqWr2; vPZGl: } goto F_rfe; F_rfe: return join('', array_unique($T63Lv)); goto AEf9B; Z47oy: $T63Lv = array(); goto yVZyK; AEf9B: } public static function string2Array($igZ39, $o8K9D = 'auto') { goto pjxFa; ivcWH: $T63Lv = array(); goto pWsQ3; pjxFa: if (is_array($igZ39)) { $igZ39 = join('::', $igZ39); if (!empty($igZ39)) { $igZ39 = ":{$igZ39}:"; } } goto GcTFF; GcTFF: $igZ39 = trim($igZ39, ':'); goto J4dEm; tBXGj: return array_unique($T63Lv); goto fB67V; pWsQ3: foreach ($igZ39 as &$aV0xo) { goto TZQu3; EtCpu: if (empty($aV0xo)) { continue; } goto SRWH0; TZQu3: $aV0xo = trim($aV0xo); goto EtCpu; SRWH0: if ($o8K9D == 'auto' && is_numeric($aV0xo)) { $T63Lv[] = intval($aV0xo); } else { $T63Lv[] = $aV0xo; } goto KEjvq; KEjvq: } goto tBXGj; J4dEm: $igZ39 = explode('::', $igZ39); goto ivcWH; fB67V: } public static function recordsString2Array(&$PcG4B, $B81eq, $o8K9D = 'auto') { goto l4Ek6; uFG9R: if (is_string($B81eq)) { $B81eq = array($B81eq); } goto l1DHL; l4Ek6: if (empty($PcG4B)) { return; } goto uFG9R; l1DHL: foreach ($PcG4B as &$ZMPsd) { foreach ($B81eq as $HQKqq) { $ZMPsd[$HQKqq] = self::string2Array($ZMPsd[$HQKqq], $o8K9D); } } goto L2wbY; L2wbY: } public static function recordsArray2String(&$PcG4B, $B81eq) { goto CHm6P; CHm6P: if (empty($PcG4B)) { return; } goto toxIP; toxIP: if (is_string($B81eq)) { $B81eq = array($B81eq); } goto ga1MI; ga1MI: foreach ($PcG4B as &$ZMPsd) { foreach ($B81eq as $HQKqq) { $ZMPsd[$HQKqq] = self::array2String($ZMPsd[$HQKqq]); } } goto ATxPk; ATxPk: } public static function mapInfo($igZ39, array $FSvUb = array()) { foreach ($igZ39 as &$aV0xo) { if (array_key_exists($aV0xo, $FSvUb)) { $aV0xo = $FSvUb[$aV0xo]; } } return $igZ39; } public static function map($igZ39, array $FSvUb = array()) { goto JKjAg; wICpz: $t2Q40 = array(); goto SyiHm; SyiHm: foreach ($igZ39 as $aV0xo) { if (array_key_exists($aV0xo, $FSvUb)) { $t2Q40[$aV0xo] = $FSvUb[$aV0xo]; } else { $t2Q40[$aV0xo] = null; } } goto bWJ6_; bWJ6_: return $t2Q40; goto XgR1l; JKjAg: if (is_string($igZ39)) { $igZ39 = self::string2Array($igZ39); } goto wICpz; XgR1l: } public static function urlJoin($iERFh, array $igZ39, $G0eKS = null, $kvYBb = 'number', $WnMhN = '_') { goto Ksprx; B1GUW: if ($iERFh) { $igZ39 = array_merge(array($iERFh), $igZ39); } goto iyNis; kzH4F: if ('number' == $kvYBb) { sort($igZ39, SORT_NUMERIC); } else { sort($igZ39, SORT_STRING); } goto B1GUW; Ksprx: if (null !== $G0eKS) { foreach ($igZ39 as $dtpXv => $aV0xo) { if ($aV0xo == $G0eKS) { unset($igZ39[$dtpXv]); } } } goto kzH4F; iyNis: return join($WnMhN, $igZ39); goto kqGz0; kqGz0: } }