阅读包含PHP二进制文件的纯文本 [英] Read plain text from binary file with PHP
本文介绍了阅读包含PHP二进制文件的纯文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
文件1:
asdffdsa
文件2:
asdfjklfdsaHGUik
我看用PHP这些二进制文件,这样我可以填充数组像明文怎么办:
$ file1_output = [ASDF,FDSA];
$ file2_output = [asdfjkl,fdsaHGUik];
解决方案
这将匹配任何单词字符(0-9,A-Z,A-Z和_):
preg_match_all(
/ [\\ x30- \\ X39 \\ X5F \\ x41- \\ X5A \\ x61- \\ X7A] + // * *正则表达式/
的file_get_contents('文件1')/ *文件的内容* /
$ file1_output / *数组来填充* /
);
File 1:
asdffdsa
File 2:
asdfjklfdsaHGUik
How do I read these binary files with PHP such that I can populate an array with the plaintext like:
$file1_output = ["asdf", "fdsa"];
$file2_output = ["asdfjkl", "fdsaHGUik"];
解决方案
This will match any word character (0-9,a-z,A-Z and _):
preg_match_all(
"/[\x30-\x39\x5F\x41-\x5A\x61-\x7a]+/", /* regexp */
file_get_contents('file1'), /* file contents */
$file1_output /* array to populate */
);
这篇关于阅读包含PHP二进制文件的纯文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文