在文本中查找指定字符串的位置

$file = fopen("1.txt",w);

$string = file_get_contents($file); //获取文本中的字符串。

先file_get_contents到$string,然后$pos=strpos

$pos = strpos("Hello world!","wo");

strpos() 函数返回字符串在另一个字符串中第一次出现的位置。

详细:http://www.w3school.com.cn/php/func_string_strpos.asp

   http://topic.csdn.net/u/20100322/13/7c6560db-0290-4d27-8861-1db7757e1b3a.html

获取指定位置以后,就可以使用fseek()函数位定写入数据。

posted @ 2012-02-24 10:05  stma  阅读(1120)  评论(0)    收藏  举报