For example if I have a .txt file with:
Hola buenos días, texto
Más texto, adiós, etc
I would like to be able to find for example the word buenos
Just to know if it has that word Thanks for any answer!
For example if I have a .txt file with:
Hola buenos días, texto
Más texto, adiós, etc
I would like to be able to find for example the word buenos
Just to know if it has that word Thanks for any answer!
What you could do is get the data from your text file via the file_get_contents() function ; and then search that content for the word you want with the strpos() function ; which checks the first occurrence of the searched string, here is an example:
You can replace the URL in the function
file_get_contents
with a local address to your text file, for example/tmp/log.txt
Another way to do it is by using
file()
andpreg_match()
(regular expressions); In essence it is the same, first you download the information from the file to a variable or object (take it to memory) once there, carry out the search with the operations on character strings that it hasphp
, I would do it like this: