This question already has an answer here:
- How to make strpos case insensitive 3 answers
I'm programming an autocomplete system and i'm using strpos to look fo occurences of a given input in a txt file.
<?php
$request=$_POST['req'];//the input received
$file=fopen('file1.txt','r');
$string='';
while(($current=fgets($file))!==false){
if (strpos($current,$request,0)!==false) {
$string=$string.$current.'<br/>';
}
};
fclose($file);
echo $string;
?>
i don't know why , but it doesn't work properly when the given input is the start of string in the file. For example:Let's say that the file contains Metal Gear Solid on a line. If i type ' tal ' --> match found but If i type ' meta ' --> match not found.
Aucun commentaire:
Enregistrer un commentaire