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

PHP 读取TXT文本有关问题

WBOY
WBOYOriginal
2016-06-13 12:52:08723browse

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;
Statement:
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