Ajax
ASP
C,C++
C#,.NET
CSS,HTML
Delphi,Kylix
Experience
Flash
Java
JavaScript
PHP
Python
QT
SQL
ShellScript
VB
U :
P :
Register
Lost Password
Other Links
Code Archive
Save Giovanni
PHP Category Code
Real Name
:
Erden
Subject
:
Yasak kelime function
Description
:
Yasak kelimeler yerine istefiğimiz karekteri koyan function
<?php function fix_badwords($str, $bad_words, $replace_str) { if (!is_array($bad_words)){ $bad_words = explode(',', $bad_words); } for ($x=0; $x < count($bad_words); $x++) { $fix = isset($bad_words[$x]) ? $bad_words[$x] : ''; $_replace_str = $replace_str; if (strlen($replace_str)==1) { $_replace_str = str_pad($_replace_str, strlen($fix), $replace_str); } $str = preg_replace('/'.$fix.'/i', $_replace_str, $str); } return $str; } /* ** Örnek: */ $str = <<<EOF Bu bizim uydurdugumuz, saçma sapan yazilarin oldugu dingil bir function. Kököz vede Vatoz yasak kelimelerdir. ;-) EOF; // yerine kullanacagimiz semboller $replace_str = "@#$*!"; // yasak kelimeler: $bad_words = array('Kököz','Vatoz'); print fix_badwords($str, $bad_words, $replace_str); print "<hr/>\n"; /* 2 nci Ornek: yasak kelimeerin yerine otomatik * karekteri koyar */ print fix_badwords($str, 'kököz, Vatoz, dingil', '*'); ?>
Rating
:
4.50
(out of 5)
Visitor Voting Booth
:
Excellent
Very Good
Good
Fair
Poor
Copyright © 2006 SharingCode.NET . All rights reserved. Hosted By: SisNetworks