[advanced search]
Results from the most recent live auction are here.
18 members in the live chat room. Join Chat!
Register Rules & FAQ NP$ Store Active Threads Mark Forums Read
Go Back   NamePros.Com > Design and Development > Programming
User Name
Password

Old 04-16-2008, 03:00 AM   · #1
baris22
NamePros Member
 
Trader Rating: (0)
Join Date: Jan 2007
Posts: 64
NP$: 0.00 (Donate)
baris22 is an unknown quantity at this point
Very basic php question

Hello.

I am using this to stop getting more than 2 of the same !?# marks.


PHP Code:
$description = preg_replace( '/([!?#])[!?#]+/', '$1', $description );



I want to do the same for
PHP Code:
<br>
but do not now how to do. Can anyone help me.


Thanks


Please register or log-in into NamePros to hide ads
__________________

Rapidme
(rapidshare application)
baris22 is offline   Reply With Quote
Old 04-16-2008, 05:04 AM   · #2
liam_d
The original NP Emo Kid
 
liam_d's Avatar
 
Name: Liam Dawe
Location: Plymouth, UK
Trader Rating: (28)
Join Date: Jan 2005
Posts: 1,577
NP$: 124.00 (Donate)
liam_d is a name known to allliam_d is a name known to allliam_d is a name known to allliam_d is a name known to allliam_d is a name known to allliam_d is a name known to all
You could just do a simple string replace:

PHP Code:
$description = str_replace('<br><br>', '<br>', $description)
liam_d is offline   Reply With Quote
Old 04-16-2008, 05:40 AM   · #3
baris22
NamePros Member
 
Trader Rating: (0)
Join Date: Jan 2007
Posts: 64
NP$: 0.00 (Donate)
baris22 is an unknown quantity at this point
Originally Posted by liam_d
You could just do a simple string replace:

PHP Code:
$description = str_replace('<br><br>', '<br>', $description)



Will this work if i have got <br><br><br><br>
__________________

Rapidme
(rapidshare application)
baris22 is offline   Reply With Quote
Old 04-16-2008, 09:55 AM   · #4
Daniel
Danltn.com
 
Daniel's Avatar
 
Name: Daniel Neville
Location: Danltn.com / Nottingham, UK
Trader Rating: (65)
Join Date: May 2007
Posts: 1,185
NP$: 0.56 (Donate)
Daniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond repute
Ethan Allen Fund Ethan Allen Fund
You could use a loop, but I prefer this. It works for <br /> too. (hopefully )

PHP Code:
$description = preg_replace('/(<br ?\/?>)(<br ?\/?>)+/i', '$1', $description);


A \s* in between the brackets may also help:
PHP Code:
$description = preg_replace('/(<br ?\/?>)\s*(<br ?\/?>)+/i', '$1', $description);


Or even...
PHP Code:
$description = preg_replace('/(<br ?\/?>)\s*(<br ?\/?>\s*)+/im', '$1', $description);



Dan

Last edited by Daniel : 04-16-2008 at 10:00 AM.
Daniel is offline   Reply With Quote
Closed Thread

NamePros is a revenue sharing forum.

Thread Tools

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


Site Sponsors
Website Header Design http://www.mobisitetrader.com/ http://www.mobisitetrader.com/
Advertise your business at NamePros
All times are GMT -7. The time now is 11:26 PM.


Powered by: vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0