i have a php file that shows recent searches on my site and displays, i am including it on my homepage with the code below: but sometimes people search bad words and i want to replace them with *** let's say someone searches "sex" and i want to show it as ***. is it possible to do it without editing recent.php? with str_replace command next to include. if so, how?
i hired a coder to do that recent.php file, but it was an encoded file and i didnt wanna pay $5 more for decoded one as i thought i wouldn't need to change anything. thats why ^^
It's possible but it depends... If the data is displayed inside recent.php then you'll have to edit it. But if recent.php only produces the final data to be displayed and the displaying of the data takes place outside recent.php then you can just look for that variable inside recent.php which is holding the final data to be displayed and include your str_replace just right below your include('recent.php');
Okay, I see. $badwords = array('sex', 'fuck', 'smurf'); ob_start(); include("recent.php"); $content = preg_replace( '/(' . implode('|', array_map('preg_quote', $badwords)) . ')/ie', 'str_repeat("*", strlen("$1"));', ob_get_contents() ); ob_end_clean(); echo $content; PHP: Untested but should work.