Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
removing of <BR> tag from the database
Old 12-06-2005, 05:18 AM removing of <BR> tag from the database
faisalzafar's Avatar
Experienced Talker

Posts: 41
Location: Pakistan
Trades: 0
hi i have the text in the database

$text= i am looking <BR> to you about 2 hour's before

and now i want the output
output = i am looking to you about 2 hour's before


if i use the preg_replace('<BR>', "", $text) then it shows the result like this
output= i am looking <> to you about 2 hour's before

if i use the htmlspecialchars($text); then it remove the <br> tag but also remove (hour's) and change it with special codes..

can any one solve my problem

Regards
Faisal Zafar
__________________
[COLOR=Pink]Faisal Zafar[/COLOR]
faisalzafar is offline
Reply With Quote
View Public Profile Visit faisalzafar's homepage!
 
 
Register now for full access!
Old 12-06-2005, 06:04 AM
Skilled Talker

Posts: 70
Trades: 0
Try escaping the quotes as it's an HTML tag, so the code should look like this:

preg replace(\"<BR>\","",$text);

not too sure about it though as I havent' been dealing with PHP databasing yet.
cerebro89 is offline
Reply With Quote
View Public Profile
 
Old 12-07-2005, 10:41 AM
Ultra Talker

Posts: 251
Location: Belgium, Antwerp, Zoersel
Trades: 0
Why would you want to use preg_replace for that? Just use str_replace('<BR>', '', $text)

If you really want ti use preg_replace however (which is slower), use preg_replace("\<BR\>", "", $text)
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

Last edited by Orodreth; 12-07-2005 at 10:43 AM..
Orodreth is offline
Reply With Quote
View Public Profile Visit Orodreth's homepage!
 
Old 12-07-2005, 01:11 PM
0beron's Avatar
Defies a Status

Posts: 1,832
Location: Somewhere else entirely
Trades: 0
You are right in saying tha you should use str_replace as this is a simple replacement, but the reason it wasn't working was because the preg functions require pattern delimeters on the ends of the pattern. Preg_replace was taking < and > to be your delimeters and not part of the pattern.

preg_replace("#<BR>#', "",$text) should work.

The pattern delimeters can be any symbol as described here:
http://www.php.net/manual/en/ref.pcre.php

I usually use # because it doesn't turn up in the rest of the pattern very often. The traditional one is / but that gets incredibly confusing with all the other / and \ that can turn up in pathnames and urls.
__________________
UPDATE 0beron SET talkupation = talkupation + lots WHERE post = 'helpful';

Please login or register to view this content. Registration is FREE
(aka MSN handwriting for forums)
0beron is offline
Reply With Quote
View Public Profile Visit 0beron's homepage!
 
Old 12-07-2005, 04:10 PM
Ultra Talker

Posts: 251
Location: Belgium, Antwerp, Zoersel
Trades: 0
Oh, I didn't know that. Thanks for the info.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
Orodreth is offline
Reply With Quote
View Public Profile Visit Orodreth's homepage!
 
Reply     « Reply to removing of <BR> tag from the database
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.20652 seconds with 12 queries