本文介绍了CKeditor删除多余的空格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将CKeditor用于文本编辑器,它不会删除多余的空格.

I'm using CKeditor for a text editor and it won't remove extra whitespace.

我尝试过

$foo = strip_tags($foo);
$foo = preg_replace('/\s+/',' ',$foo);

我不知道从这里删除空格的任何其他方法.有什么想法吗?

I don't know of any other way to remove whitespace from here. Any ideas?

谢谢

推荐答案

解决了如果有人好奇的话,我通过在他们进入数据库之前清理它们来解决了这个问题.

Solved If anybody is curious, I solved this by cleaning them before they went into the database.

  $cpbody = trim($_POST['cbody']);

  $cpbody = preg_replace("/\<p\>\&nbsp\;\<\/p\>/", "", $cpbody);
  $cpbody = preg_replace("/\&nbsp\;+/", " ", $cpbody);
  $cpbody = preg_replace("/\s+/", " ", $cpbody);

  $cpbody = htmlentities($cpbody);

这篇关于CKeditor删除多余的空格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-11 13:38