当前位置:网站首页>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"
}
边栏推荐
- Thread pool batch processing data
- Installation du tutoriel MySQL 8.0.22 par centos8
- KMP idea and template code
- Appnuim environment configuration and basic knowledge
- Technologists talk about open source: This is not just using love to generate electricity
- Zzuli:1067 faulty odometer
- LCD之MIPI协议的一些说明
- MySQL foundation --- query (learn MySQL foundation in 1 day)
- Operator details
- I want to understand the swift code before I learn it. I understand it
猜你喜欢
Huawei Hongmeng OS, is it OK?
mysql事务和隔离级别
青训营--数据库实操项目
Cube magique infini "simple"
Fabric. JS iText sets the color and background color of the specified text
centos8安装mysql8.0.22教程
2022-2-14 learning xiangniuke project - section 23, section 5, development login and exit functions
数理统计与机器学习
Storage of data
《CGNF: CONDITIONAL GRAPH NEURAL FIELDS》阅读笔记
随机推荐
"Original, excellent and vulgar" in operation and maintenance work
Zzuli:1064 encrypted characters
在线音乐播放器app
460. LFU 缓存 双向链表
Thread pool batch processing data
all3dp.com网站中全部Arduino项目(2022.7.1)
GRBL 软件:简单解释的基础知识
XSS basic content learning (continuous update)
Gee series: unit 9 generate sampling data in GEE [random sampling]
Financial portal related information
2022-2-14 learning xiangniuke project - section 23, section 5, development login and exit functions
How to write good code - Defensive Programming Guide
Basic use of form
Online music player app
File contains vulnerability (I)
Brew install * failed, solution
[paper translation] gcnet: non local networks meet squeeze exception networks and beyond
How to change the IP address of computer mobile phone simulator
H5 jump applet
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