Modify from comma separated keyword to space separated keyword

The php codes below is used to come out with an array of keywords when the input keywords are separated by comma (,) or semi colon (;). I want to change this such that it gives an array when the input keywords are separated by a space. How should I modify the code below ?

[php]function show_keywords($id,$type)
{
$kw="";
$kw_lite="";
if($rs->row[“keywords”]!="")
{
$keywords=explode(",",str_replace(";",",",$rs->row[“keywords”]));
for($i=0;$i<count($keywords);$i++)
{
$keywords[$i]=trim($keywords[$i]);
if($keywords[$i]!="")
{
$kw.="

 “.$keywords[$i].”
";
$kw_lite.="".$keywords[$i]." ";
}
}
	if($global_settings["watermarkinfo"] and $type=="photo")
	{
	
		$wposit="<table border='0' cellpadding='0' cellspacing='1'><tr>";
		for($i=1;$i<10;$i++)
		{
			$wsel="b";
			if($watermark_position==$i){$wsel="o";}

			if(site_root==""){$wpath="/";}
			else{$wpath=site_root."/";}

			$wposit.="<td><img src='".$wpath.$site_template_url."images/".$wsel.".gif' width='5' height='5'></td>";
			if($i%3==0){$wposit.="</tr><tr>";}
		}
		$wposit.="</tr></table>";
		$kw.="<div style='margin-bottom:3px'><table border='0' cellpadding='0' cellspacing='0'><tr><td><input type='checkbox' name='swatermark' value='".$rs->row["watermark"]."'></td><td>&nbsp;</td><td>".word_lang("watermark")."</td><td>&nbsp;</td><td>".$wposit."</td></tr></table></div>";
	}
}
if($kw!="")
{
	$boxcontent=str_replace("{WORD_KEYWORDS}",word_lang("keywords").":",$boxcontent);
	$boxcontent=str_replace("{KEYWORDS}","<form method='get' action='".site_root."/' style='margin:0px'>".$kw."<input type='submit' value='".word_lang("search")."'></form>",$boxcontent);
	$boxcontent=str_replace("{KEYWORDS_LITE}",$kw_lite,$boxcontent);
}
else
{
	$boxcontent=str_replace("{WORD_KEYWORDS}","",$boxcontent);
	$boxcontent=str_replace("{KEYWORDS}","",$boxcontent);
	$boxcontent=str_replace("{KEYWORDS_LITE}","",$boxcontent);
}

}[/php]

Change:

[php]$keywords=explode(",",str_replace(";",",",$rs->row[“keywords”]));[/php]

To:

[php]$keywords=explode(",",str_replace(" “,”,",$rs->row[“keywords”]));[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service