当前位置:网站首页>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"
}
边栏推荐
- [paper translation] gcnet: non local networks meet squeeze exception networks and beyond
- Disable access to external entities in XML parsing
- Fabric. JS iText superscript and subscript
- Thread pool overview
- Cube magique infini "simple"
- Brew install * failed, solution
- [golang syntax] be careful with the copy of slices
- Visual studio import
- js判断移动端还是pc端
- Cambrian was reduced by Paleozoic venture capital and Zhike shengxun: a total of more than 700million cash
猜你喜欢

Technologists talk about open source: This is not just using love to generate electricity

Visual Studio導入

The Hong Kong Stock Exchange learned from US stocks and pushed spac: the follow-up of many PE companies could not hide the embarrassment of the world's worst stock market

"Original, excellent and vulgar" in operation and maintenance work

Alibaba: open source and self-developed liquid cooling data center technology

ThreadLocal memory leak

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

Storage of data

With an amount of $50billion, amd completed the acquisition of Xilinx
![Gee series: unit 7 remote sensing image classification using GEE [random forest classification]](/img/01/ba9441b7b1efaed85c464316740edb.jpg)
Gee series: unit 7 remote sensing image classification using GEE [random forest classification]
随机推荐
简单封装 js并应用
H5 jump applet
460. LFU 缓存 双向链表
Financial portal related information
Fabric. JS right click menu
Applet jumps to official account
Innovation never stops -- the innovation process of nvisual network visualization platform for Excel import
"Simple" infinite magic cube
Fabric. JS basic brush
1036 Boys vs Girls
【LeetCode】Day92-盛最多水的容器
软件测试答疑篇
Cambrian was reduced by Paleozoic venture capital and Zhike shengxun: a total of more than 700million cash
“简单”的无限魔方
Database batch insert data
Gee series: unit 8 time series analysis in Google Earth engine [time series]
Zzuli:1065 count the number of numeric characters
h5跳小程序
Practice C language advanced address book design
Zzuli: maximum Convention and minimum common multiple