I have this .php file that searches for text from a .txt file and compares it to what the user has typed in. I'm not sure how to make it do a case insensitive search of the .txt file.
<?php
$search = $_POST['search'];
$text = file_get_contents('name_list.txt');
$lines = explode("
", $text);
if(in_array($_POST['search'], $lines)){
echo stristr($search, " is compatible!");
} else {
echo stristr($search, " is not compatible!");
}
?>
Here is the javascript it is linked to:
$(function() {
$(".search_button").click(function() {
var searchString = $("#search_box").val();
var data = 'search='+ searchString;
if(searchString) {
// ajax call
$.ajax({
type: "POST",
url: "do_search.php",
data: data,
beforeSend: function(html) {
$("#results").html('');
$("#searchresults").show();
$(".word").html(searchString);
},
success: function(html){
$("#results").show();
$("#results").append(html);
}
});
}
return false;
});
});
Any help/comments appreciated.