 |
Results from the most recent live auction are here.
18 members in the live chat room. Join Chat!
| |
04-16-2008, 03:00 AM
|
· #1 | | NamePros Member | 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 but do not now how to do. Can anyone help me.
Thanks |
| |
04-16-2008, 05:04 AM
|
· #2 | | The original NP Emo Kid Name: Liam Dawe Location: Plymouth, UK Join Date: Jan 2005
Posts: 1,577
NP$: 124.00 ( Donate)
| You could just do a simple string replace: PHP Code: $description = str_replace('<br><br>', '<br>', $description)
|
| |
04-16-2008, 05:40 AM
|
· #3 | | NamePros Member |
Will this work if i have got <br><br><br><br> |
| |
04-16-2008, 09:55 AM
|
· #4 | | Danltn.com Name: Daniel Neville Location: Danltn.com / Nottingham, UK Join Date: May 2007
Posts: 1,185
NP$: 0.56 ( Donate)
| 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.
|
| |
Posting Rules
| You may not post new threads You may not post replies You may not post attachments You may not edit your posts HTML code is Off | | | |