提取TXT里数据报错

WBOY
Release: 2016-06-13 12:02:11
Original
1078 people have browsed it

提取TXT里数据出错

本帖最后由 bcwr2 于 2014-07-12 14:08:44 编辑 $file = '15.txt';  

$content = file_get_contents($file);  
$array = explode("\r\n", $content);  
 for($i=0; $i {  
preg_match("/\杰\德(.*)\'/U",$array[$i],$dss);
echo $dss[$i];
 } 
想提取文本里所有的 “杰德”到'之间的数据,我这样写对吗,怎么都提不出来呢
------解决方案--------------------
引用:
preg_match("/杰德(.*)'/U", $array[$i], $dss);
Copy after login

这个妥妥的可以哇,要内容里面有然后输出的时候你的输出方式不对,要输出的为$dss[2]的数据,才是你想要的数据,你用个$i能输出就奇怪了。
------解决方案--------------------
1、print_r($array); 看看数据是否正常

2、输出改为:
echo $dss[1];  
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!