我有兩個字符串是從文件中拉出來的。我試圖先通過做一個str_replace去掉他們的標籤(如),並用一個空格替換它們。不幸的是,這似乎不起作用,因爲當我在窗體中回顯結果時,我仍然看到標籤。str_replace工作不正常PHP
任何想法?
# Trim the title and description of their tags. Keep only text.
$title_new = $file_lines[$title_line];
str_replace("<title>"," ", $title_new);
str_replace("</title>"," ", $title_new);
$desc_new = $file_lines[$desc_line];
str_replace("<description>"," ", $desc_new);
str_replace("</description>"," ", $desc_new);
# Echo out the HTML form
echo "<form action=\"rewrite.php\" method=\"post\">";
echo "Title: <input type=\"text\" name=\"new_title\" size=\"84\" value=\"".$title_new."\">";
echo "</input>";
echo "<br>Article Body:<br>";
echo "<textarea rows=\"20\" cols=\"100\" wrap=\"hard\" name=\"new_desc\">".$desc_new."</textarea><br>";
echo "<input type=\"hidden\" name=\"title_line\" value=\"".$title_line."\">";
echo "<input type=\"hidden\" name=\"title_old\" value=\"".$file_lines[$title_line]."\">";
echo "<input type=\"hidden\" name=\"desc_line\" value=\"".$desc_line."\">";
echo "<input type=\"hidden\" name=\"desc_old\" value=\"".$file_lines[$desc_line]."\">";
echo "<input type=\"submit\" value=\"Modify\" name=\"new_submit\">";
你試過strip_tags嗎? – locrizak 2011-05-16 17:47:00
第一天寫PHP,讓我有些鬆懈。 – n0pe 2011-05-16 18:02:28