Home > Backend Development > PHP Tutorial > PHP 读取TXT文本有关问题

PHP 读取TXT文本有关问题

WBOY
Release: 2016-06-13 11:16:58
Original
878 people have browsed it

PHP 读取TXT文本问题
我想读取a.txt中第二个$,到第三个$之间的数据怎么弄谢谢了!!! 


------解决方案--------------------
$fp = fopen('filename', 'r');<br />$num = 0;<br />$s = '';<br />while($ch = fgetc($fp)) {<br />  if($ch == '$') {<br />    $num++;<br />    if($num > 2) break;<br />  }elseif($num == 2) $s .= $ch;<br />}<br />echo $s;
Copy after login
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