- array_combine: documentation ( source)
- preg_match_all: documentation ( source)
- var_export: documentation ( source)
<?php
$string = <<<MIKROTIK
add name=100YER on-login=":do {:put \"a\";} on-error={};" rate-limit=256k/512k
MIKROTIK;
var_export(
preg_match_all(
'~(\w+(?:-\w+)*)=(?|"([^"\\\\]*(?:\\\\.[^"\\\\]*)*)"|([^" ]+))~',
$string,
$out
)
? array_combine($out[1], $out[2])
: []
);