I am trying to remove whitespace with PHP from something like this: <body> Hi </body> Code (markup): Which outputs simply "Hi" in HTML. But I don't want my PHP script running the whitespace. How would I get rid of the whitespace, i've tried the following: str_replace(" ", "", $something); trim($something); Anyone have any ideas?
You could try a regular expression. Something like /<body>\s*([\s\S]+?)\s*<\/body>/s Code (markup): coupled with the preg_match function might do the trick. You'll need to check that regular expression though, I haven't tested it and I'm not confident enough in my regex knowledge to say it will definitely work.
Well, I'm not worried about the <body> tags, i was just using those as an example. But lets see... Nope didn't work
I think I'm fine now, Since it's in a MySQL database I used Like %whatever% . Works like a charm, I can't believe I didn't think of that in the first place