当前位置:网站首页>PHP read file (read JSON file, convert to array)
PHP read file (read JSON file, convert to array)
2022-07-02 05:49:00 【Jill__ er】
The contents of the document
{
"address":"192.168.1.0",
"RemotePort":"10081"
}
Format after reading
array(2) {
'address' =>
string(11) "192.168.1.0"
'RemotePort' =>
string(5) "10081"
}
Realization way :
<?php
$config = array();
// Print the contents of the read file
var_dump(file_get_contents("ConfigFile1.conf"));
// Format conversion of the read file contents
$config = json_decode(file_get_contents("ConfigFile1.conf"), true);
var_dump($config);
?>
Show results :
[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"
}
边栏推荐
- Php/js cookie sharing across domains
- Zzuli:1065 count the number of numeric characters
- Ls1046nfs mount file system
- Record sentry's path of stepping on the pit
- Fabric. JS iText set italics manually
- [personal test] copy and paste code between VirtualBox virtual machine and local
- php获取cpu使用率、硬盘使用、内存使用
- Zzuli:1067 faulty odometer
- Grbl software: basic knowledge of simple explanation
- Generate QR code
猜你喜欢
KMP idea and template code
RNN recurrent neural network
【論文翻譯】GCNet: Non-local Networks Meet Squeeze-Excitation Networks and Beyond
Visual Studio導入
【pyinstaller】_ get_ sysconfigdata_ name() missing 1 required positional argument: ‘check_ exists‘
软件测试 - 概念篇
青训营--数据库实操项目
3D printer G code command: complete list and tutorial
Fabric. JS activation input box
Thunder on the ground! Another domestic 5g chip comes out: surpass Huawei and lead the world in performance?
随机推荐
Opencv LBP features
2022-2-14 learning xiangniuke project - Section 7 account setting
c语言中的几个关键字
JVM class loading mechanism
Installation du tutoriel MySQL 8.0.22 par centos8
TypeScript的泛型和泛型约束
kmp思想及模板代码
Pytorch Chinese document
How to write good code - Defensive Programming Guide
Zzuli:1069 learn from classmate Z
Huawei Hongmeng OS, is it OK?
Sliding window on the learning road
Alibaba: open source and self-developed liquid cooling data center technology
php按照指定字符,获取字符串中的部分值,并重组剩余字符串为新的数组
1036 Boys vs Girls
文件包含漏洞(二)
H5 jump applet
A collection of commonly used plug-ins for idea development tools
金融门户相关信息
mysql事务和隔离级别