I want to produce search result all letters that is caps or small,but now it's displaying exact keywords result only,so that i changed my original code $pattern = "/".$searchTerm."([a-zA-Z0-9])*/";
to like this $pattern = "/".$searchTerm."([a-zA-Za-ZA-z0-9])*/";
but this display some errors and output not coming
Error :
Warning: preg_match_all(): Compilation failed: range out of order in character class at offset 14 in /var/app/current/WS/search.php on line 30
Warning: Invalid argument supplied for foreach() in /var/app/current/WS/search.php on line 31 {"message":"success","response":1,"result":[]}
My search code :
if($searchTerm&&$searchType)
{
if($searchType=='hash') {
$query = "SELECT hashTag FROM `".$table."` WHERE hashTag LIKE '%#".$searchTerm."%'";
$stmt = $database->prepare($query);
// $stmt->bind_param('s',$searchTerm);
$stmt->execute();
$stmt->store_result();
if($stmt->num_rows>0) {
$tempArray = array();
$stmt->bind_result($hashTag);
while ($row =$stmt->fetch()) {
$pattern = "/".$searchTerm."([a-zA-Za-ZA-z0-9])*/";
preg_match_all($pattern,$hashTag,$matches);
foreach ($matches[0] as $key => $value) {
$finalArray[$value] = "";
}
}
foreach ($finalArray as $key => $value) {
$tempArray = array();
$tempArray['hash'] = $key ;
array_push($megaArray, $tempArray);
}
$stmt->free_result();
$stmt->close();
$finalArray = array();
$finalArray = $megaArray;
$message = "success";
$response = 1;
}
}
What is the solution to produce the result to the search term is caps or small?