dougai0138 2015-10-12 17:19
浏览 27

在搜索时转义连字符( - )

How can modify below if statement to get the same search result when i enter R1 and R-1 most my data contains - Forexample SUPER POWER DRIVE RADIAL R-1 on the current search I can get all result containing R-1 but i want also show all results containing R-1 when i enter R1 as a search key.

$txtsize is search textbox

 if (($txtsize!="") && (preg_match("/\b".preg_quote($txtsize,'/')."\b/i", $row['Tire_Size']) || ($row['Tire Size']==$txtsize)))

Thanks Kinfe

  • 写回答

1条回答 默认 最新

  • duanfu4446 2015-10-12 17:23
    关注

    You can use str_replace, i.e.:

    $txtsize = str_replace("R-1", "R1", $txtsize);
    

    评论

报告相同问题?