function one() {
console.log('AAAAAAAAAA');
one = () => {};
}
function once(f) {
let called = false;
return function() {
if (!called) {
called = true;
return f.apply(this, arguments);
}
};
}
const one = once(function() {
console.log('AAAAAAAAAA');
});
<?php
$str = "ЭНИ-601[2к[10Вт;20Вт];4к[10Вт;20Вт;30Вт];8к[70Вт;80Вт]];";
$str = preg_replace("#([а-яА-Я\d\-]+)#u","\"\$1\"",$str);
$str = str_replace(array("[","]"),array(":{","}"),$str);
$str = preg_replace("#\{([^{};]+?(;[^}]+?)*?)\}#u","[\$1]",$str);
$str = str_replace(";",",",$str);
$str = '{'.substr($str,0,-1).'}';
print_r(json_decode($str,true));
echo PHP_EOL;
Array
(
[ЭНИ-601] => Array
(
[2к] => Array
(
[0] => 10Вт
[1] => 20Вт
)
[4к] => Array
(
[0] => 10Вт
[1] => 20Вт
[2] => 30Вт
)
[8к] => Array
(
[0] => 70Вт
[1] => 80Вт
)
)
)