|
Posted by kurt.milligan on 04/16/06 14:22
Hello
Unless I'm missing something, I think the problem is that you are not
capturing the output of str_replace(). It does not modify the string
in-place; it returns the modified version of the string. So, instead
of:
str_replace('</rss>', '', $xmlFileContents);
str_replace('</channel>', '', $xmlFileContents);
do:
$xmlFileContents = str_replace('</rss>', '', $xmlFileContents);
$xmlFileContents = str_replace('</channel>', '', $xmlFileContents);
HTH
-Kurt
marcomputers@gmail.com wrote:
> Hi,
>
> I'm trying to automatically update an existing rss podcast file using
> php and the str_replace function.
> Every time I add a media file, it should read the .rss file into a
> string, take the closing </channel> and </rss> tags out of it, and add
> the new rss file info to the end of the existing string, writing it
> back to the rss file. However, str_replace will not replace the
> </channel> and </rss> tags with ' '. I'm new to php, any help would be
> appreciated.
>
> Start Code:
> ----------------
> $xmlFile = "/home2/kingshar/public_html/podcast_test.rss";
> $xmlReadHandle = fopen($xmlFile, 'r') or die("Cannot open podcast
> file");
> $xmlFileContents = fread($xmlReadHandle, filesize($xmlFile));
> fclose($xmlFile);
>
>
> //Search and delete closing rss tag
> str_replace('</rss>', '', $xmlFileContents);
> //Search and delete closing channel tag
> str_replace('</channel>', '', $xmlFileContents);
>
[Back to original message]
|