Skip to content
Advertisement

print an array as code

I want to convert a big yaml file to PHP array source code. I can read in the yaml code and get back a PHP array, but with var_dump($array) I get pseudo code as output. I would like to print the array as valid php code, so I can copy paste it in my project and ditch the yaml.

Advertisement

Answer

You’re looking for var_export.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement