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

PHP 读取TXT文本问题

WBOY
Release: 2016-06-23 14:02:27
Original
957 people have browsed it

我想读取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;
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