I'm generating localization files in Laravel that look something like this:
<?php
return [
'hello' => 'world',
'foo' => 'bar',
];
Just a normal array, nothing fancy. I'm looking for a way to do this, I've looked at the serialize
method but it doesn't fit my needs. Is there a way to do this that I'm not aware of?
Also note that my array only consists of string keys and values. Since this is localization work, some strings are UTF-8.
var_export
works well for this, it will pretty-print your array a lot like the format you specified above
echo(var_export($array_variable, true));