I'm brand new to php, while I've read books on it, I've only recently began generating my own code.
My idea was to take each row of a column, break it up into individual words, and scan each of those words for the @ symbol. If it is found, store it in a seperate array until the process is complete, if not, proceed to next row.
I have commented out my thought process so it should be fairly easy for someone to narrow down my error, but I am fairly certain it is the way I am using the "foreach" or the "if $value == $findme" (probably both). ANY ideas or suggestions would be very greatful. (I connect using the include from a diff file, don't worry about that it's done correctly as ive used it plenty of times in other scripts).
<?php
//convert email column to string
$result = mysql_query("SELECT email FROM users");
//create please array to store valid email addresses
$please=array();
$findme = "@";
//for each row of 'email' in table 'users'
while($row = mysql_fetch_array($result)) {
$address = (string)$row['email'];
//take the entire string and explode each word into array $words using the ' ' as a delimiter
$words=array(explode(' ', $address));
//loop over $words applying its value to $value
foreach($words as $value) {
//if the $value has $findme (the @)
if($value == "$findme"){
//echo $value and push it to $please array
echo "I have a @ in my string! <br />";
array_push($please, "$value);
}else{
echo "Doesnt have @ in string! <br />"
unset($value);
}
}
?>