<?php 
function search($champs,$exp)
{
	$champs = explode(',',$champs);
	$exp = strtolower($exp);
	$exp = str_replace(',','+',$exp);
	$exp = str_replace(' ','+',$exp);
	$exp = str_replace('et','+',$exp);
	$exp = str_replace('ou','+',$exp);
	$exp = str_replace(';','+',$exp);
	$exp = str_replace('?','+',$exp);
	$exps = explode('+',$exp);
	$Exps =array();
	foreach($exps as $elt)
	{
		$elt = trim($elt);
		if(!empty($elt)) $Exps[]=$elt;
	}
	$CONDS = array();
	foreach($Exps as $exp)
	{
		$cond = array();
		foreach($champs as $champ)
		{
			$cond[]= "$champ LIKE '%$exp%'"; 
		}
		$CONDS []=  "(".implode(' OR ',$cond).")";
	}
	if(!empty($CONDS)){$fin = "(".implode(' AND ',$CONDS).")";return $fin;}
	
	return '1';
}
?>