My advice will be very specific to your flat input array. It seems that you would like the output from var_export ()
but without the old skool array syntax and without the multiline formatting.
The following will use modern brace syntax and replace the newlines with single spaces. My snippet is not designed for multidimensional arrays and can be broken if your keys or values contain newlines. For your basic associative array, it is safe to use.
Code: (Demo)
$array = [10 => 11.22, 20 => 22.33, 30 => 33.44];
echo preg_replace(
['/^array \(\s+/', '/,?\R?\)$/', '/$\R /m'],
['[', ']', ' '],
var_export($array, true)
);
Output:
[10 => 11.22, 20 => 22.33, 30 => 33.44]
If you require more complicated data sets to be reformatted, then this would become a far less trivial task that should consider implementing a tokenizer.