I'm trying to search a "keywords" field in a Microsoft Access database which can contain more than one word. E.g. "Cat", "Dog", "Cat Dog" etc. All of the keywords will then be listed on a page and when clicked will display any record containing that keyword. The problem I'm having is getting only one isntance of each word displayed and cannot figure out how to do it. So with the example "Cat", "Dog", "Cat Dog", "Mouse Dog" the only listed words should be "Cat" "Dog" "Mouse".
When using the following code:
<?php
$items = odbc_exec($odbc, "SELECT keywords FROM faq WHERE visible = 'true'") or die (odbc_errormsg());
while ($detail = odbc_fetch_array($items))
{
$exploded = explode(" ",$detail['keywords']);
$unique = array_unique($exploded);
foreach($unique as $unique)
{
var_dump($unique);
}
}
?>
It returns:
string(0) "" string(0) "" string(0) "" string(0) "" string(0) "" string(3) "Dog" string(3) "Cat" string(3) "Dog" string(3) "Cat" string(3) "Dog" string(3) "Cat" string(5) "Mouse" string(3) "Cat" string(3) "Dog"
I've attached a word document of other examples I have tried but with no luck
If anyone can provide any help I'd really appreciate it. Many thanks
[attachment deleted by admin]