-1

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.

Helen Che
  • 1,951
  • 5
  • 29
  • 41

3 Answers3

1

You can store your data as an JSON string with json_encode

hsz
  • 148,279
  • 62
  • 259
  • 315
1

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));
Manmaru
  • 578
  • 3
  • 8
1

Try this:

echo "<pre>";
print_r($metaDesc);
echo "</pre>";
exit;
Gaurav Dave
  • 6,838
  • 9
  • 25
  • 39