32 lines
725 B
PHP
32 lines
725 B
PHP
<?php
|
|
|
|
namespace mt;
|
|
|
|
use phpcommon;
|
|
|
|
class StrHelper {
|
|
|
|
public static function parseList($val, $separators)
|
|
{
|
|
$values = array();
|
|
if (!empty($val) && count($separators) > 0) {
|
|
self::parse($val, $separators, 0, $values);
|
|
}
|
|
return $values;
|
|
}
|
|
|
|
private static function parse($data, $separators, $i, &$arr) {
|
|
$strs = explode($separators[$i], $data);
|
|
foreach ($strs as $str) {
|
|
if ($i + 1 < count($separators)) {
|
|
$item = array();
|
|
self::parse($str, $separators, $i + 1, $item);
|
|
array_push($arr, $item);
|
|
} else {
|
|
array_push($arr, $str);
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|