Hi I want to loop the following code with data from a MySql database: elseif (wordsExist($search, array('$data1[$id]'))) { $redir = "$data2[$id]"; } PHP: I have the following code on top of the script: include("connect.php"); $query =mysql_query("SELECT * FROM `engines`"); $i=0; while($row = mysql_fetch_array($query )) { $data1[$i]=$row['name']; $data2[$i]=$row['url']; $i++; } PHP: Can anyone explain how to do this? Thanks in advance
(I assume "wordsExist" isnt a custom function..) You can use the in_array function http://php.net/manual/en/function.in-array.php
Okey but how can I loop it? I am trying to re-direct the page if it finds certain keywords in the text The keyword it need to find is in a mysql database.. The same is the redirect URL.
$text = "long text with many words"; $words_array = array("text","many"); $words = explode(" ",$text); foreach($words as $word){ if(in_array($word,$words_array)){ redirect($word);// redirects to "text" } } PHP: If I understood you correctly.