<?php
{
function word_censor($str, $censored, $replacement = '')
{
{
return $str;
}
$str = ' '.$str.' ';
// \w, \b and a few others do not match on a unicode character
// set for performance reasons. As a result words like über
// will not match on a word boundary. Instead, we'll assume that
// a bad word will be bookeneded by any of these characters.
$delim = '[-_\'\"`(){}<>\[\]|!?@#%&,.:;^~*+=\/ 0-9\n\r\t]';
foreach ($censored as $badword)
{
if ($replacement != '')
{
}
else
{
}
}
}
}
echo word_censor
('Texto do comentario com um palavrao', array('palavrao'), '---'); echo "\n";
echo word_censor
('Texto do comentario com um palavrao', array('palavrao'));
PD9waHAKCmlmICggISBmdW5jdGlvbl9leGlzdHMoJ3dvcmRfY2Vuc29yJykpCnsKICAgIGZ1bmN0aW9uIHdvcmRfY2Vuc29yKCRzdHIsICRjZW5zb3JlZCwgJHJlcGxhY2VtZW50ID0gJycpCiAgICB7CiAgICAgICAgaWYgKCAhIGlzX2FycmF5KCRjZW5zb3JlZCkpCiAgICAgICAgewogICAgICAgICAgICByZXR1cm4gJHN0cjsKICAgICAgICB9CgogICAgICAgICRzdHIgPSAnICcuJHN0ci4nICc7CgogICAgICAgIC8vIFx3LCBcYiBhbmQgYSBmZXcgb3RoZXJzIGRvIG5vdCBtYXRjaCBvbiBhIHVuaWNvZGUgY2hhcmFjdGVyCiAgICAgICAgLy8gc2V0IGZvciBwZXJmb3JtYW5jZSByZWFzb25zLiBBcyBhIHJlc3VsdCB3b3JkcyBsaWtlIMO8YmVyCiAgICAgICAgLy8gd2lsbCBub3QgbWF0Y2ggb24gYSB3b3JkIGJvdW5kYXJ5LiBJbnN0ZWFkLCB3ZSdsbCBhc3N1bWUgdGhhdAogICAgICAgIC8vIGEgYmFkIHdvcmQgd2lsbCBiZSBib29rZW5lZGVkIGJ5IGFueSBvZiB0aGVzZSBjaGFyYWN0ZXJzLgogICAgICAgICRkZWxpbSA9ICdbLV9cJ1wiYCgpe308PlxbXF18IT9AIyUmLC46O15+Kis9XC8gMC05XG5cclx0XSc7CgogICAgICAgIGZ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