这篇文章主要介绍了php中将一段数据存到一个txt文件中,并获取其内容显示的实现代码,需要的朋友可以参考下
这里的数据可以为基本数据类型,数组,对象等;
在存储的时候可以用serialize进行序列化,,但取的时候要先用unserialize反序列化。
当然也可以使用json_encode,这里数组可以以键值对存取,取时要用json_decode转义。
"上海","文化"=>"西安","首都"=>"北京"); //将数组存到指定的text文件中 file_put_contents("E:/data.txt",json_encode($data)); //获取数据 $datas = json_decode(file_get_contents("E:/data.txt")); print_r($datas); ?>

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

SublimeText3 Linux new version
SublimeText3 Linux latest version

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function
