简体   繁体   English

用空格CKEditor替换

[英]Replace   with space CKEditor

I need to save a text from CKEditor component to my DB and i need to replace by normal space.I already tried : 我需要将文本从CKEditor组件保存到数据库中,并且需要用普通空格替换。我已经尝试过:

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

but it doesn't work! 但这不起作用! Any idea? 任何想法?

NB My string does have < and > so this workaround doesn't work too: How to replace &nbsp; 注意:我的字符串确实具有<和>,因此此解决方法也无法正常工作: 如何替换&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>

It's more likely that the NBSP is an actual character, not an entity. NBSP更有可能是实际角色,而不是实体。

Try: 尝试:

$newstring = str_replace("\xA0"," ",$newString);

Found a workaround for CKEditor: 找到了CKEditor的解决方法:

In config.js: Add the following line config.basicEntities = false; 在config.js中:添加以下行config.basicEntities = false; at the end 在末尾

basic entities include : nbsp,gt,lt,amp 基本实体包括:nbsp,gt,lt,amp

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM