feat: util/simpleSerialize 추가

This commit is contained in:
2022-05-17 00:07:18 +09:00
parent 56fd26935d
commit 2cb697f3dc
2 changed files with 38 additions and 0 deletions
+21
View File
@@ -850,4 +850,25 @@ class Util extends \utilphp\util
yield $a => $b;
}
}
public static function simpleSerialize(string|int|float ...$values): string{
$result = [];
foreach($values as $value){
if(is_string($value)){
$length = mb_strlen($value);
$result[] = "str({$length},{$value})";
continue;
}
if(is_int($value)){
$result[] = "int({$value})";
continue;
}
if(is_float($value)){
$value = number_format($value, 6, '.', '');
$result[] = "float({$value})";
continue;
}
}
return join('|', $result);
}
};