Wild cards (*) in Arrays
Posted: Tue Aug 19, 2008 7:55 pm
Hello, I was wondering if you can implement wildcards (*) when searching an array. What I am trying to do is configure a spam-detecting script, if the script find said spam, the website or link will be starred out. For example: if a user puts "Discount watches at http://www.site.com! into the message I want the script to edit the website out so it appears as "Discount watches at http://www.****.***! Here is some starting code:
If wildcards can, infact, be used can you please check my code to see it I used it correctly. Thanks! 
Code: Select all
<?php
/* From a previous form. */
$message = $_POST['message'];
/* Anything using site.whatever, site DOT whatever, site(.)whatever, site[.]whatever, and site dot whatever is dubbed spam. */
$spam = array("*.*", "*DOT*", "*(.)*", "*[.]*", "*dot*");
/* Searches the message to see if there is any spam, if there is spam then edit it out, otherwise send the message. */
if (in_array($message, $array)){
some code
}else{
echo "Your message has been posted!";
}
?>