打印一个数组作为代码 [英] print an array as code

查看:84
本文介绍了打印一个数组作为代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将一个大的Yaml文件转换为PHP数组源代码.我可以读取yaml代码并获取一个PHP数组,但是使用var_dump($ array)可以获得伪代码作为输出.我想将数组打印为有效的php代码,因此我可以将其复制粘贴到我的项目中并抛弃Yaml.

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.

推荐答案

您正在寻找

You're looking for var_export.

这篇关于打印一个数组作为代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆