Hi,
I a string that is coming from my database table say $needle. If te needle is not in my array, then I want to add it to my array.
If it IS in my array then so long as it is in only twice, then I still want to add it to my array (so three times will be the maximum)
In order to check to see is if $needle is in my $haystack array, do I need to loop through the array with strpos() or is there a quicker method ?
There are many needles in the table so I start by looping through the select result.
This is the schematic of what I am trying to do...
$haystack = array();
while( $row = mysql_fetch_assoc($result)) {
$needle = $row['data'];
$num = no. of times $needle is in $haystack // $haystack is an array
if ($num < 3 ) {
$$haystack[] = $needle; // hopfully this adds the needle
}
} // end while. Get next needle.
Does anyone know how do I do this bit:
$num = no. of times $needle is in $haystack
thanks