Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/246.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 文件获取Word文档中的内容_Php_Strpos - Fatal编程技术网

Php 文件获取Word文档中的内容

Php 文件获取Word文档中的内容,php,strpos,Php,Strpos,我正在使用下面的代码尝试使用PHP在word文档中查找“术语”。 当然,这不是像word文档那样打开二进制文件的正确方法,但是“$fileContent”中格式错误的字符串对我来说已经足够了。 但是,在搜索文档中当前存在的术语时,“stripos”函数没有按预期工作 $fileContent = file_get_contents($filePath); $posFileContent = stripos($fileContent,$term); if ($posFileContent !==

我正在使用下面的代码尝试使用PHP在word文档中查找“术语”。 当然,这不是像word文档那样打开二进制文件的正确方法,但是“$fileContent”中格式错误的字符串对我来说已经足够了。 但是,在搜索文档中当前存在的术语时,“stripos”函数没有按预期工作

$fileContent = file_get_contents($filePath);
$posFileContent = stripos($fileContent,$term);
if ($posFileContent !== false) {
    echo "Found!!";
    $value += $FACTOR_SEC;
}
观察:对$fileContent执行var_转储显示文档的正确内容,当然还有格式错误的问题,但术语仍然存在

更多信息:

var_转储($期限)

字符串(10)“创新”

变量转储($fileContent)

字符串(10240)”��ࡱ�;�� ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������� ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������根 进入������������������������������������������������������������������������ ��������!���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������� ���� �FMicrosoft Word Dokument MSWordDocWord.Document.8�9�q[Z��ZNormal1$*$3B*OJQJCJmH 什哈普希特^贾杰(H9BA)@���BAbsatz Standardschriftf�标题���x$OJQJCJPJ^JaJ.B.文本正文��x/ 列表^J@@标题�x�x$CJ6^JaJ]&�2&Index$^Jd����� � ddPG�时代 新罗马书5�符号3&�阿里亚尔格��纽约时报5�SimSun5�曼加尔�微软 亚平5��曼加尔布��H��"�5_��5_' 0 0��������哦��+'��0 | 8@LXd p��0@@@�{� �.�@��M��0� 草兰80元��������������B ��兰姆达 关于我们的发展Lambda开发创新的软件产品,引领我们的客户走向成功。我们专注于 移动应用程序、网络工具和管理系统。我们的团队参与了整个过程,从一个想法诞生的地方开始,一直到未来 通过产品规范,直到其在适当的技术中实施。&*:>��J L� � ����������CJ>*5aJ\OJQJ/:;B*ph”“”CJ@�6> *5aJ\OJQJCJ$>*5aJ$\CJ8>5aJ8\ ( � �����$美元“��/ ��=!�n“�n#�n$�n3P(20����՜.��+,��D��՜.��+,��\����根 进入��?
$fileContent = file_get_contents($filePath);
$termArray = str_split($term);
$newTerm = '';
foreach ($termArray as $charTerm) {
    $newTerm = $newTerm.$charTerm;
    $newTerm = $newTerm."\0";
}
if (stripos($fileContent,$newTerm) !== false) {
    // Term found in doc
}