<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace ModStart\Core\Util; use Illuminate\Support\Str; class TagUtil { public static function seperated2Array($uhujs, $ar7E_ = ',') { if (',' == $ar7E_) { $uhujs = str_replace(array('，'), ',', $uhujs); } return array_filter(explode(',', $uhujs)); } public static function seperated2String($uhujs, $ar7E_ = ',') { $WZJqt = self::seperated2Array($uhujs, $ar7E_); return self::array2String($WZJqt); } public static function array2String(array $uhujs) { goto lrw3b; zX4n8: foreach ($uhujs as &$vIPao) { goto cCjCp; psDBA: if ($vIPao == '' || Str::contains($vIPao, ':')) { continue; } goto W2HZd; W2HZd: $T9avD[] = ':' . $vIPao . ':'; goto BXu1H; cCjCp: $vIPao = trim($vIPao); goto psDBA; BXu1H: } goto YjiR1; YjiR1: return join('', array_unique($T9avD)); goto CUE5l; lrw3b: $T9avD = array(); goto zX4n8; CUE5l: } public static function string2Array($uhujs, $zANe9 = 'auto') { goto MgwMZ; zAhpV: foreach ($uhujs as &$vIPao) { goto Gb9M3; p8fne: if ($zANe9 == 'auto' && is_numeric($vIPao)) { $T9avD[] = intval($vIPao); } else { $T9avD[] = $vIPao; } goto KhJrw; YUj00: if (empty($vIPao)) { continue; } goto p8fne; Gb9M3: $vIPao = trim($vIPao); goto YUj00; KhJrw: } goto ybzTW; ybzTW: return array_unique($T9avD); goto RKIDF; FZfp1: $uhujs = explode('::', $uhujs); goto SjFdq; SjFdq: $T9avD = array(); goto zAhpV; MgwMZ: if (is_array($uhujs)) { $uhujs = join('::', $uhujs); if (!empty($uhujs)) { $uhujs = ":{$uhujs}:"; } } goto mtMSW; mtMSW: $uhujs = trim($uhujs, ':'); goto FZfp1; RKIDF: } public static function recordsString2Array(&$laNjB, $DFWfJ, $zANe9 = 'auto') { goto We5oe; nqRk2: foreach ($laNjB as &$H7gaA) { foreach ($DFWfJ as $GUcFO) { $H7gaA[$GUcFO] = self::string2Array($H7gaA[$GUcFO], $zANe9); } } goto Ux3jb; FnbOE: if (is_string($DFWfJ)) { $DFWfJ = array($DFWfJ); } goto nqRk2; We5oe: if (empty($laNjB)) { return; } goto FnbOE; Ux3jb: } public static function recordsArray2String(&$laNjB, $DFWfJ) { goto bVgPj; y3TwM: if (is_string($DFWfJ)) { $DFWfJ = array($DFWfJ); } goto XIXf_; XIXf_: foreach ($laNjB as &$H7gaA) { foreach ($DFWfJ as $GUcFO) { $H7gaA[$GUcFO] = self::array2String($H7gaA[$GUcFO]); } } goto zIaR1; bVgPj: if (empty($laNjB)) { return; } goto y3TwM; zIaR1: } public static function mapInfo($uhujs, array $OhfIK = array()) { foreach ($uhujs as &$vIPao) { if (array_key_exists($vIPao, $OhfIK)) { $vIPao = $OhfIK[$vIPao]; } } return $uhujs; } public static function map($uhujs, array $OhfIK = array()) { goto nZlCL; LyS3t: return $XTSE5; goto Km_FG; XRy2Q: $XTSE5 = array(); goto k3UtA; nZlCL: if (is_string($uhujs)) { $uhujs = self::string2Array($uhujs); } goto XRy2Q; k3UtA: foreach ($uhujs as $vIPao) { if (array_key_exists($vIPao, $OhfIK)) { $XTSE5[$vIPao] = $OhfIK[$vIPao]; } else { $XTSE5[$vIPao] = null; } } goto LyS3t; Km_FG: } public static function urlJoin($XVqXz, array $uhujs, $MI9wx = null, $g41EO = 'number', $fkmnj = '_') { goto VhZPs; VhZPs: if (null !== $MI9wx) { foreach ($uhujs as $aDVv6 => $vIPao) { if ($vIPao == $MI9wx) { unset($uhujs[$aDVv6]); } } } goto V9pdV; YNvml: if ($XVqXz) { $uhujs = array_merge(array($XVqXz), $uhujs); } goto cOTmA; V9pdV: if ('number' == $g41EO) { sort($uhujs, SORT_NUMERIC); } else { sort($uhujs, SORT_STRING); } goto YNvml; cOTmA: return join($fkmnj, $uhujs); goto o8OWc; o8OWc: } }