How to format var_export to php5.4 array syntax

后端 未结 5 676
北海茫月
北海茫月 2020-12-30 21:37

There are lots of questions and answers around the subject of valid php syntax from var outputs, what I am looking for is a quick and clean way of getting the output of

5条回答
  •  再見小時候
    2020-12-30 22:36

    For anyone looking for a more modern-day solution, use the Symfony var-exporter, also available as a standalone library on composer, but included in Symfony default.

    composer require symfony/var-exporter
    
    use Symfony\Component\VarExporter\VarExporter;
    
    // ...
    
    echo VarExporter::export($arr)
    

提交回复
热议问题