腦友記廣場 -> 新手上路 -> strpos 問題 登錄 -> 註冊 -> 回復主題 -> 發表主題

fireghost 2007-04-22 14:43
我想問點解唔可以用 strpos 黎知道中文字係邊個位置, 就算係 mb_strpos 都係唔得
CODE:


$cinema="-l";     //所有戲院
$picture="-p";     //所有劇照
$comment="-rep";   //所有影評
$site=$_GET['link'];   // e.g.     /070403/28/250w5.html
$requesturl="[url]http://hk.movies.yahoo.com[/url]";
$fp = fopen("$requesturl$site", "r");

while(!feof($fp))   {
  $line .= fgets($fp,256);
}

fclose($fp);

// fix the range of content
eregi("<div id=\"movtit\">(.*)width:380", $line, $matches);

$contents = $matches[1];
$pictureexist = strpos($contents, $picture.".html");
$contents = eregi_replace("<script(.*)script>", "", $contents);
$contents = str_replace("<img src=\"[url]http://hk.yimg.com/i/mov[/url]", "<br><img src=\"[url]http://hk.yimg.com/i/mov[/url]", $contents);
$contents = preg_replace("/<img src=\"http:\/\/ls.hk.yimg.com\/hk\/providers\/mov3\/tb.*?<\/a><\/td>/", "", $contents);

// change the table format to a line break
$contents = eregi_replace("\<div id=\"doth\"\>", "<br><br>", $contents);
$contents = eregi_replace("\<tr\>", "<br>", $contents);
$contents = eregi_replace("\<div id=\"movtit\"\>", "<br>", $contents);
$contents = eregi_replace("\</a\>", "</a><br>", $contents);
$contents = eregi_replace("<br> | ", "", $contents);

$allowed_tags = "<img>, <br>, <b>, <p>, <ul>, <li>";
$contents = strip_tags($contents, $allowed_tags);
echo $contents."<br>\n";

//======================================================================================================
// list all the picture out
// 照 = 戲院劇照
echo mb_strpos($contents, "照", 0, "BIG5"); // 不能夠return 數字
echo mb_strpos($contents, "<br>", 0, "BIG5"); // 能夠return 數字
echo strpos($contents, "照"); // 不能夠 return 數字
echo strpos($contents, "<br>"); // 能夠 return 數字



就係o係最尾個幾行 echo

唔該!!

maninnet 2007-04-22 22:14
講真, strpos 通常應用於一行文字, 如網頁咁大內容, 用 ereg 好過

fireghost 2007-04-24 01:10
好, 等我試下先, thank you.


查看完整版本: [-- strpos 問題 --] [-- top --]


Powered by PHPWind v4.0.1 Code © 2003-05 PHPWind
Gzip enabled

You can contact us