用nodejs实现PHP的print_r函数代码
2023-06-13 09:15:19 时间
functionergodic(obj,indentation){
varindent=" "+indentation;
if(obj.constructor==Array||obj.constructor==Object){
for(varpinobj){
if(obj[p].constructor==Array||obj[p].constructor==Object){
console.log(indent+"["+p+"]=>"+typeof(obj)+"");
console.log(indent+"{");
ergodic(obj[p],indent);
console.log(indent+"}");
}elseif(obj[p].constructor==String){
console.log(indent+"["+p+"]=>""+obj[p]+""");
}else{
console.log(indent+"["+p+"]=>"+obj[p]+"");
}
}
}
}
functionprint_r(obj){
console.log("{")
ergodic(obj,"");
console.log("}")
}
varstu={"name":"Alan","grade":{"Chinese":120,"math":130,"competition":{"NOI":"Firstprize"}}};
print_r(stu);
相关文章
- linux安装nodejs环境_ubuntu安装nodejs
- linux如何安装node.js_centos安装nodejs
- nodejs部署
- 如何运行PHP代码_运行php网站
- 编写NodeJs脚本实现接口请求
- 我用nodejs实现了热加载接口文件,感觉又离“serverless”进了一步
- 二次优化更优雅-nodejs前端容器化核心实战
- 无界 | Bncr | Boundless Nodejs Chat Robot 机器人框架安装使用教程
- Nodejs获取网络数据并生成Excel表格详解编程语言
- 手把手教你做爬虫—基于NodeJs详解编程语言
- 数据库PHP究竟如何还原MySQL数据库?(php还原mysql)
- Redis实战:PHP开发者必备技能(redis实战php)
- 脚本Linux实现自动化执行PHP脚本(linux自动执行php)
- 学习PHP玩转MySQL数据库(php操作mysql方法)
- PHP专业连接MySQL:实现快速代码.(php连接mysql数据库代码)
- 实现使用PHP实现的Redis乐观锁(redis乐观锁php)
- Linux系统下如何快速安装PHP(linux命令安装php)
- PHP如何使用Redis连接: 代码实例(php连接redis代码)
- PHP如何开启MSSQL支持?(php怎么开启mssql)
- PHP连接MSSQL实现数据交互(mssql类php)
- Nodejs与Oracle相结合,开拓新技术时代(node oracle)
- php去除换行符的方法小结(PHP_EOL变量的使用)
- PHP获取php,mysql,apche的版本信息示例代码