note 95722 added to function.substr

From: Date: Mon, 18 Jan 2010 14:38:29 +0000
Subject: note 95722 added to function.substr
Groups: php.notes 
Request: Send a blank email to php-notes+get-165074@lists.php.net to get a copy of this message
//censor entries //cenzor wpisów <?php function cenzor($content){ $words_list=@file('test.txt');//file with profanity (after lines) foreach($words_list as $badword){ $badword=trim($badword); $badwordtop=substr($badword, 0,2);//2, the first signs $badwordlength=strlen($badword); $x=3; // continued from 3 mark while($x <= $badwordlength){ $badwordtop.='*'; //add * $x++; } $content=str_replace($badword, $badwordtop, $content); } return $content; //returning results } echo cenzor($_POST['content']); //example: //$_POST['content'] includes the word home //If the file test.txt would be the word home //the emergence of words home - ho** ?> ---- Server IP: 82.177.164.100 Probable Submitter: 80.51.74.103 ---- Manual Page -- http://www.php.net/manual/en/function.substr.php Edit -- https://master.php.net/note/edit/95722 Del: integrated -- https://master.php.net/note/delete/95722/integrated Del: useless -- https://master.php.net/note/delete/95722/useless Del: bad code -- https://master.php.net/note/delete/95722/bad+code Del: spam -- https://master.php.net/note/delete/95722/spam Del: non-english -- https://master.php.net/note/delete/95722/non-english Del: in docs -- https://master.php.net/note/delete/95722/in+docs Del: other reasons-- https://master.php.net/note/delete/95722 Reject -- https://master.php.net/note/reject/95722 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#165074) next »