当前位置:网站首页>php读文件(读取json文件,转换为数组)
php读文件(读取json文件,转换为数组)
2022-07-02 05:47:00 【杰儿__er】
文件内容
{
"address":"192.168.1.0",
"RemotePort":"10081"
}
读取后的格式
array(2) {
'address' =>
string(11) "192.168.1.0"
'RemotePort' =>
string(5) "10081"
}
实现方式:
<?php
$config = array();
//打印读取到的文件内容
var_dump(file_get_contents("ConfigFile1.conf"));
//对读取到的文件内容进行格式转换
$config = json_decode(file_get_contents("ConfigFile1.conf"), true);
var_dump($config);
?>
显示结果:
[Running] php 1_duwenjian_1.php
string(51) "{
"address":"192.168.1.0",
"RemotePort":"10081"
}"
array(2) {
'address' =>
string(11) "192.168.1.0"
'RemotePort' =>
string(5) "10081"
}
边栏推荐
- Fabric. JS round brush
- Vscode paste image plugin saves image path settings
- Usage record of vector
- all3dp. All Arduino projects in com website (2022.7.1)
- Fabric. JS upload local image to canvas background
- MySQL foundation --- query (learn MySQL foundation in 1 day)
- 来啦~ 使用 EasyExcel 导出时进行数据转换系列新篇章!
- 简单封装 js并应用
- 【pyinstaller】_ get_ sysconfigdata_ name() missing 1 required positional argument: ‘check_ exists‘
- Foreign trade marketing website system development function case making
猜你喜欢

《CGNF: CONDITIONAL GRAPH NEURAL FIELDS》阅读笔记

【论文翻译】GCNet: Non-local Networks Meet Squeeze-Excitation Networks and Beyond

Fabric. JS activation input box

Pytorch Basics

Conglin environmental protection rushes to the scientific and Technological Innovation Board: it plans to raise 2billion yuan, with an annual profit of more than 200million yuan

【技术随记-08】

centos8安装mysql8.0.22教程

Lantern Festival gift - plant vs zombie game (realized by Matlab)

软件测试基础篇

Centos8 installation mysql8.0.22 tutorial
随机推荐
“简单”的无限魔方
【技术随记-08】
VSCode paste image插件保存图片路径设置
ERP management system development and design existing source code
Win10 copy files, save files... All need administrator permission, solution
Php/js cookie sharing across domains
Simply encapsulate JS and apply it
Generate QR code
Fabric. JS basic brush
Online English teaching app open source platform (customized)
Ls1046nfs mount file system
3D 打印机 G 代码命令:完整列表和教程
Operator details
Pytorch Chinese document
Principle and implementation of parallax effect
正则表达式总结
Disable access to external entities in XML parsing
数理统计与机器学习
Zzuli:1061 sequential output of digits
brew install * 失败,解决方法