dongliqian6245 2012-11-20 06:41
浏览 115
已采纳

无效字符替换为空格

I'm currently trying to filter alphanumeric characters only. Therefore, I've tried a following Zend Function,

$filter = new Zend_Filter_Alnum(array('allowwhitespace' => true));
$return = $filter->filter('This is (my) content: 123');

This actually amazing but the issue is here I need to replaced the characters with white space. For example if I enter "Hel#o wor*d" it has to be "Hel o wor d". Aslo I've tried php str_replace function it's actually good but I've to define there a loads of invalid characters. Could any please tell me how to do this easily ?

  • 写回答

2条回答 默认 最新

  • dqyuipw44576 2012-11-20 08:14
    关注

    You can create a custom filter for that Writing Custom Filters

    ** For your requirement copy the Zend Alphanumeric fiter (Zend_Filter_Alnum) and replace preg_replace($pattern, '', (string) $value); (line 144) to
    preg_replace($pattern, ' ', (string) $value);

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 LiBeAs的带隙等于0.997eV,计算阴离子的N和P
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 matlab有关常微分方程的问题求解决
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?
  • ¥100 求三轴之间相互配合画圆以及直线的算法