Computing.Net > Forums > Web Development > String replacement problem in PHP

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

String replacement problem in PHP

Reply to Message Icon

Name: Alirezan1
Date: July 10, 2004 at 22:39:57 Pacific
OS: XP/LINUX
CPU/Ram: AMD
Comment:

Hi everyone!
My problem is that, I am trying to write a file using PHP and there are 3 inputs to the file "HEADLINE, BODY and LINK". I want to stor the inputs to a file names "news.htm". Everything seems to be working fine, until I try to store ' in the file which ends up looking like \'
I tried to edit my code so that it replaces \' with ' . But it does not work. Please tell me what is wrong with my code. Thank you

Alireza Nematollahi

<?php
$strheadline = $HTTP_GET_VARS ['headline'];
$strbody = $HTTP_GET_VARS ['body'];
$strlink = $HTTP_GET_VARS ['link'];

$find = "/.*'.*/";
$replace = "Alireza";

if ( preg_match ("/.*'.*/", $strbody))
{
echo "FOUND";
$strbody = str_replace ("/.*'.*/", "AA", $strbody);
}
else
{
echo "NOT FOUND";
}

echo "
$strbody";

$strhtmlheadline = '<p align="center"><span id="headline">' . $strheadline . '</span> </p>';
$strhtmlbody = '

<span class="storyCaption"> ' . $strbody . '</span>...</p>';
$strhtmllink = '

<span style="font-size: 8pt">Read more</span></p>';

$fp = fopen ("news.htm", "w+");

fputs ($fp, $strhtmlheadline);
fputs ($fp, $strhtmlbody);
fputs ($fp, $strhtmllink);

fclose ($fp);


?>




Sponsored Link
Ads by Google

Response Number 1
Name: -Bryan-
Date: July 10, 2004 at 23:29:17 Pacific
Reply:

http://www.php.net/manual/en/function.stripslashes.php



0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Web Development Forum Home


Sponsored links

Ads by Google


Results for: String replacement problem in PHP

Stuck with ereg_replace in PHP www.computing.net/answers/webdevel/stuck-with-eregreplace-in-php/3003.html

Error in PHP Script www.computing.net/answers/webdevel/error-in-php-script/2599.html

RSS parser code problem in PHP www.computing.net/answers/webdevel/rss-parser-code-problem-in-php/754.html