Question

I need to save a text from CKEditor component to my DB and i need to replace   by normal space.I already tried :

$newString = str_replace(" "," ",$newString);

but it doesn't work! Any idea?

N.B. My string does have < and > so this workaround doesn't work too:How to replace &nbsp; to space?

String to be saved:

<p><strong>Objectifs</strong></p> <ul> <li><em>Accompagner&nbsp;: Accompagner par le biais de suivi individuel et de groupe, les familles vers la prise en charge de leur santé globale.</em></li> </ul> <ul> <li><em>Informer&nbsp;: Devenir une référence en santé préventive et mieux-être auprès des nouvelles familles. Rendre accessible toute information concernant la péri et post natalité des participants par tous les médiums disponibles.</em></li> </ul> <ul> <li><em>Enrichir&nbsp;: Guider les nouveaux parents à travers des expérimentations pratiques pour&nbsp; optimiser les apprentissages réalisés face à la santé globale de la famille et ainsi accroître leurs compétences et leurs capacités d''agir. </em></li> </ul> <ul> <li><em>Relier&nbsp;: Relier les différents intervenants en santé afin d''assurer une accessibilité et une vrai continuité de soins et de services aux familles.</em></li> </ul>

Was it helpful?

Solution

Found a workaround for CKEditor:

In config.js: Add the following line config.basicEntities = false; at the end

basic entities include : nbsp,gt,lt,amp

OTHER TIPS

It's more likely that the NBSP is an actual character, not an entity.

Try:

$newstring = str_replace("\xA0"," ",$newString);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top