進行中

About a function strlen(Banned words(

I have a function, function is that.

<?php

function sanitize_core($text)

{

global $bannedWords;

$text = htmlspecialchars($text, ENT_NOQUOTES);

$text = str_replace("\n\r","\n",$text);

$text = str_replace("\r\n","\n",$text);

$text = str_replace("\n"," <br> ",$text);

$number_word = explode(" ",$text);

for($x=0;$x<count($number_word);$x++)

{

for ($i=0;$i < count($bannedWords);$i++)

{

if (stripos($text, $bannedWords[$i]) !== false)

{

/*$pos = stripos($text, $bannedWords[$i]);

$word = substr($text,$pos,strlen($bannedWords[$i]));

$first = substr($text,0,$pos);

$final = substr($text,$pos+strlen($bannedWords[$i]),strlen($text)-($pos+$bannedWords[$i]));

$text = $first.str_repeat("*",strlen($bannedWords[$i])).$final;*/

$text = str_ireplace($bannedWords[$i], str_repeat("*",strlen($bannedWords[$i])), $text);

}

//$text = str_ireplace(' '.$bannedWords[$i].' ',' '.str_repeat("*",strlen($bannedWords[$i])).' ',' '.$text.' ');

}

}

$search = array('Ç','ç','Ğ','ğ','ı','İ','Ö','ö','Ş','ş','Ü','ü');

$replace = array('c','c','g','g','i','i','o','o','s','s','u','u');

$text = str_replace($search,$replace,$text);

$text = trim($text);

return $text;

}

$bannedWords = array( 'fuck','0','sakaci' );

$test_word = "a 1 2 5 s p o c X";

echo sanitize_core($test_word);

?>

The functions is works perfect, so dont remove anything, ı wanna only add something.

if I write only one letter, it should replace with * so you need to add minumum strlen.

Examples,

if I echo

H e l l o

or

H

all will * because if one letter after space , it will * (because minumum word should 2 )

if I echo only "H" it will also *

So edit this function and send me.

スキル: PHP

さらに表示: global p, final trim, banned, count words text, php search replace, php function write, words letter, search edit function, function number words spanish, global banned, php edit search function, count words php, banned text php, php count words text, search replace, software requirements banned words, function edit php, banned words, php count words, substr

採用者について:
( 91件のレビュー ) sanki, Turkey

プロジェクトID: #6396268

1人のフリーランサーが、このジョブに平均$10で入札しています

NayaPakistan

A proposal has not yet been provided

$10 USD / 時間
(208件のレビュー)
6.4