欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 编程语言 > php >内容正文

php

php分开每个字,PHP,分解每个句子之间有特殊字符的文本文件

发布时间:2025/3/20 php 62 豆豆
生活随笔 收集整理的这篇文章主要介绍了 php分开每个字,PHP,分解每个句子之间有特殊字符的文本文件 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

我有一个带有Unicode编码的文本文件(有时它包含一个希伯来语),其内容是文本,在每个句子之间有一个像这样的两个特殊字符(■■)(alt + 2 + 5 + 4),这是一个示例

"How are you, It's a cool day .. how can I read this sentence in a string variable with the quotes."■■

"This is second sentence I want it in another variable or in second cell in array."■■

This is third sentence. It is without quotes I want to read it to a string.■■

This is fourth sentence it includes an enter,

The fourth sentence isn't completed right yet.

The sentence doesn't completed until the special character is appears,

Maybe there a lot of lines in the same sentence.

This is the last part of the sentence■■

"This is the fifth sentence", this is the second part of the fifth sentence■■

Maybe between every two sentences there is a lot of empty lines, This is the sixth sentence■■

Thanks I wish anyone can help me with this, This is the last sentence■■我对这个代码,但它不起作用:

$file=file_get_contents("text_file.txt");

$file_= urldecode($file);

$sentences = explode('■■',$file_);

?>当我为第一句(我没有把所有文件放在简单的阅读文件中)制定指定的代码时,我会得到

Array ( [0] => ��"How are you, It s a cool day .. how can I read this sentence in a string variable with the quotes."�%�%并获得相同的其他句子..(我看到在同一行中的所有句子)我的意思是没有进入

另一件事,我想忽略两句话之间的界限,我的意思是忽略■■后面的空行

总结

以上是生活随笔为你收集整理的php分开每个字,PHP,分解每个句子之间有特殊字符的文本文件的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。