Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.
If the asker does not get an answer then they have 10 days to request a refund.
$10
get_content - remove all additional white space
Hello,
I am trying to remove all multiple white spaces from get_content();
But in my html post editor I just have some extra white spaces, and there are no   characters, but in the output of the get_the_content, there additional   replacing the additional white space.
So I tried this...
<?php
$termsConditions = str_replace(' '," ",get_the_content());
echo preg_replace('/\s+/',' ',$termsConditions);
?>But still there are multiple
  are in my text.How are these being generated? or why is my php above not working?
Can anyone help please.
Thanks
This question has been answered.
Josh Cranwell | 01/25/13 at 5:38pm
Edit
Tutorial: How to assign prize money
(7) Responses
See a threaded view of answers?
Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.
-

Last edited:
01/25/13
5:46pmFrancisco Javier Carazo Gil says:With this you can clean every HTML special character: $Content = preg_replace("/&#?[a-z0-9]{2,8};/i","",$Content);
-

Last edited:
01/25/13
5:51pmMax Matloka says:
$content = preg_replace( '/\s+/', ' ', get_the_content() );
echo $content;
It should work :)
Edit
or use this if it is non-breaking space
$content = str_replace(' '," ",get_the_content());
$content = preg_replace( '/\s+/', ' ', $content );
echo $content;
Previous versions of this answer: 01/25/13 at 5:51pm | 01/25/13 at 5:51pm | 01/25/13 at 5:51pm
-

Last edited:
01/26/13
1:52pm -

Last edited:
01/25/13
5:47pmFrancisco Javier Carazo Gil says:And this I think is better for you:
$string = htmlentities($string, null, 'utf-8');
$string = str_replace(" ", "", $string); -

Last edited:
01/27/13
12:46pm -

Last edited:
01/27/13
12:47pm -

Last edited:
01/27/13
12:47pm
This question has expired.
John Cotton, Josh Cranwell, Arnav Joy, Dbranes, Naveen Chand voted on this question.
Current status of this question: Completed
Please log in to add additional discourse to this page.
Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.
If the asker does not get an answer then they have 10 days to request a refund.
