find and replace

General discussions related to php

Moderators: macek, egami, gesf

scribeke
New php-forum User
New php-forum User
Posts: 8
Joined: Sat Sep 28, 2002 2:18 am

find and replace

Postby scribeke » Sat Sep 28, 2002 4:38 am

Hi, can someone give me the code to find and replace in php?

I want to find \" and replace it by " but I don't know how to do this, can anyone help me ?


thx

Peter

DoppyNL

Postby DoppyNL » Sat Sep 28, 2002 5:02 am

simply use str_replace:

Code: Select all

$new_value = str_replace('\"','"',$original_value);

pay close attention to the use of '

Greetz Daan

scribeke
New php-forum User
New php-forum User
Posts: 8
Joined: Sat Sep 28, 2002 2:18 am

Postby scribeke » Sat Sep 28, 2002 5:18 am

damn I thought this would fix my problem but it doesn't, let me explain you what I'm trying to do:

I'm trying to create a script that can change the html code of a page, it worked well axcept for one problem, it always puts quotes " or ' like \" or \' if I want to change the code through this function : fwrite($file_pointer, $input); the $input is submitted from another page and so every " or ' this $input contains he outputs like \" \' because he fills in the $input by "text of input" I guess, does anybody has an idea how to change this because pages that contain scriptfunction or where I do a <body bgcolor="red"> don't work ...

thx

scribeke

p.s. DoppyNL -> from netherlands or belgium ?

DoppyNL

Postby DoppyNL » Sat Sep 28, 2002 7:03 am

try the function stripslashes -> see http://www.php.net/stripslashes

Just look at my profile to see wich wet country it is :)

Greetz Daan

scribeke
New php-forum User
New php-forum User
Posts: 8
Joined: Sat Sep 28, 2002 2:18 am

Postby scribeke » Sat Sep 28, 2002 8:46 am

ah ok het werkt bedankt hé :wink:

scribeke (belgium)


Return to “PHP General”

Who is online

Users browsing this forum: No registered users and 2 guests