How can I replace <br>, \r, \n with " ". Which is an empty space. Is there a way to detect these characters in a string and replace them with a single white space?
garyjohnson 14 Junior Poster
Recommended Answers
Jump to Post@sparker, I think it's fair to assume he's talking about PHP here, give that he posted the question in the PHP forum.
To answer the question: in PHP, simple string replacement can be done using the
Jump to Post
preg_*
functions tend to slower than the 'straight'str_*
functions in my experience, so if you can avoid regex do so. Remember thatstr_replace()
can take arrays as parameters which will help avoid having to make repeated calls to this function.
Jump to PostFor the record, I was just expanding a little (possibly needlessly - but there again I am a post whore ;) ) on Atli's post.
All 10 Replies
sparker 0 Newbie Poster
<M/> 170 Why so serious? Featured Poster
Atli 182 Posting Pro
<M/> commented: ah, much bettter +8
<M/> 170 Why so serious? Featured Poster
mmcdonald 28 Posting Pro

diafol
mmcdonald 28 Posting Pro
Atli 182 Posting Pro

diafol
mmcdonald 28 Posting Pro
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.