Переезд lookstats отовсюду в 1 класс.
This commit is contained in:
26
_incl_data/class/Core/ConversionHelper.php
Normal file
26
_incl_data/class/Core/ConversionHelper.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace Core;
|
||||
|
||||
class ConversionHelper
|
||||
{
|
||||
/** <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> data ('a=1|b=2|c=3') <20><> <20><> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> [a=>1, b=>2, c=>3].
|
||||
* @param string $dataString
|
||||
* @return array
|
||||
*/
|
||||
public static function dataStringToArray(string $dataString): array
|
||||
{
|
||||
$arr = json_decode(str_replace(['=', '|'], ['":', ',"'], '{"' . $dataString . '}'), true);
|
||||
return $arr ?: [];
|
||||
}
|
||||
|
||||
/** <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> [a=>1, b=>2, c=>3] <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> data ('a=1|b=2|c=3') <20><><EFBFBD> <20><>.
|
||||
* @param array $dataArray
|
||||
* @return string
|
||||
*/
|
||||
public static function arrayToDataString(array $dataArray): string
|
||||
{
|
||||
$str = json_encode($dataArray);
|
||||
return $str ? str_replace(['":', ',"', '{"', '}'], ['=', '|'], $str) : '';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user