<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace ModStart\Core\Util; use Illuminate\Support\Str; class TagUtil { public static function seperated2Array($rtKBf, $D83IL = ',') { if (',' == $D83IL) { $rtKBf = str_replace(array('，'), ',', $rtKBf); } return array_filter(explode(',', $rtKBf)); } public static function seperated2String($rtKBf, $D83IL = ',') { $Of2_w = self::seperated2Array($rtKBf, $D83IL); return self::array2String($Of2_w); } public static function array2String(array $rtKBf) { goto V0UKn; TfKt6: foreach ($rtKBf as &$J1QDP) { goto qQL4s; kzebU: if ($J1QDP == '' || Str::contains($J1QDP, ':')) { continue; } goto PPlta; PPlta: $QzV0B[] = ':' . $J1QDP . ':'; goto oIfho; qQL4s: $J1QDP = trim($J1QDP); goto kzebU; oIfho: } goto utbq0; V0UKn: $QzV0B = array(); goto TfKt6; utbq0: return join('', array_unique($QzV0B)); goto yks3m; yks3m: } public static function string2Array($rtKBf, $oahh2 = 'auto') { goto yPJIr; l4GCj: $QzV0B = array(); goto E7o9j; lLfgx: return array_unique($QzV0B); goto uy32D; F2ry1: $rtKBf = trim($rtKBf, ':'); goto sPy3h; E7o9j: foreach ($rtKBf as &$J1QDP) { goto tkymK; jfgYG: if (empty($J1QDP)) { continue; } goto ibyuR; tkymK: $J1QDP = trim($J1QDP); goto jfgYG; ibyuR: if ($oahh2 == 'auto' && is_numeric($J1QDP)) { $QzV0B[] = intval($J1QDP); } else { $QzV0B[] = $J1QDP; } goto KYB8q; KYB8q: } goto lLfgx; sPy3h: $rtKBf = explode('::', $rtKBf); goto l4GCj; yPJIr: if (is_array($rtKBf)) { $rtKBf = join('::', $rtKBf); if (!empty($rtKBf)) { $rtKBf = ":{$rtKBf}:"; } } goto F2ry1; uy32D: } public static function recordsString2Array(&$J2nWJ, $JraPN, $oahh2 = 'auto') { goto YqQ52; YqQ52: if (empty($J2nWJ)) { return; } goto GDNGs; GDNGs: if (is_string($JraPN)) { $JraPN = array($JraPN); } goto yo1Np; yo1Np: foreach ($J2nWJ as &$FN3l1) { foreach ($JraPN as $dwwIV) { $FN3l1[$dwwIV] = self::string2Array($FN3l1[$dwwIV], $oahh2); } } goto xZQCM; xZQCM: } public static function recordsArray2String(&$J2nWJ, $JraPN) { goto TM4qj; uJF1s: foreach ($J2nWJ as &$FN3l1) { foreach ($JraPN as $dwwIV) { $FN3l1[$dwwIV] = self::array2String($FN3l1[$dwwIV]); } } goto pYnWe; glO3I: if (is_string($JraPN)) { $JraPN = array($JraPN); } goto uJF1s; TM4qj: if (empty($J2nWJ)) { return; } goto glO3I; pYnWe: } public static function mapInfo($rtKBf, array $L1ufl = array()) { foreach ($rtKBf as &$J1QDP) { if (array_key_exists($J1QDP, $L1ufl)) { $J1QDP = $L1ufl[$J1QDP]; } } return $rtKBf; } public static function map($rtKBf, array $L1ufl = array()) { goto S3rMw; my_Zz: $ZwnIC = array(); goto w0FPs; w0FPs: foreach ($rtKBf as $J1QDP) { if (array_key_exists($J1QDP, $L1ufl)) { $ZwnIC[$J1QDP] = $L1ufl[$J1QDP]; } else { $ZwnIC[$J1QDP] = null; } } goto bLqqh; bLqqh: return $ZwnIC; goto XoRkQ; S3rMw: if (is_string($rtKBf)) { $rtKBf = self::string2Array($rtKBf); } goto my_Zz; XoRkQ: } public static function urlJoin($VzVt9, array $rtKBf, $n0FrU = null, $J2ao8 = 'number', $csb5e = '_') { goto HOfZQ; ilXzW: return join($csb5e, $rtKBf); goto gDkCj; HMEy5: if ($VzVt9) { $rtKBf = array_merge(array($VzVt9), $rtKBf); } goto ilXzW; HOfZQ: if (null !== $n0FrU) { foreach ($rtKBf as $ouMWs => $J1QDP) { if ($J1QDP == $n0FrU) { unset($rtKBf[$ouMWs]); } } } goto N7xas; N7xas: if ('number' == $J2ao8) { sort($rtKBf, SORT_NUMERIC); } else { sort($rtKBf, SORT_STRING); } goto HMEy5; gDkCj: } }