当前位置:网站首页>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"
}
边栏推荐
猜你喜欢
With an amount of $50billion, amd completed the acquisition of Xilinx
Disable access to external entities in XML parsing
KMP idea and template code
Brew install * failed, solution
all3dp.com网站中全部Arduino项目(2022.7.1)
Practice C language advanced address book design
2022-2-15 learning xiangniuke project - Section 8 check login status
mysql的约束总结
OLED12864 液晶屏
[paper translation] gcnet: non local networks meet squeeze exception networks and beyond
随机推荐
I want to understand the swift code before I learn it. I understand it
[golang syntax] be careful with the copy of slices
Fabric. JS upload local image to canvas background
idea开发工具常用的插件合集汇总
Online English teaching app open source platform (customized)
all3dp.com网站中全部Arduino项目(2022.7.1)
Cambrian was reduced by Paleozoic venture capital and Zhike shengxun: a total of more than 700million cash
记录sentry的踩坑之路
中小型项目手撸过滤器实现认证与授权
[personal test] copy and paste code between VirtualBox virtual machine and local
all3dp. All Arduino projects in com website (2022.7.1)
Grbl software: basic knowledge of simple explanation
Centos8 installation mysql8.0.22 tutorial
[paper translation] gcnet: non local networks meet squeeze exception networks and beyond
在线音乐播放器app
6. Network - Foundation
“簡單”的無限魔方
vite如何兼容低版本浏览器
【技术随记-08】
RGB 无限立方体(高级版)