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

PHP 读取TXT文本问题

WBOY
WBOYOriginal
2016-06-23 14:02:27958browse

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


回复讨论(解决方案)

计数呀
读到一个 $ 就计数器加一

问题是怎么计数了。。不太会。。谢谢了

$fp = fopen('filename', 'r');$num = 0;$s = '';while($ch = fgetc($fp)) {  if($ch == '$') {    $num++;    if($num > 2) break;  }elseif($num == 2) $s .= $ch;}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