Fastest way to find string into a file PHP with ~ 5000 lines -


i know fastest way find string in file using php. have been told quickest way read file using file() function, find string in whole file have foreach. whereas if use file_get_contents or something, have strpos() on file.

the point not know if strpos() faster (i think is). know if, better content of file , strpos() once, or file line line , strpos() foreach line until find value (or until end if value not found).

using strpos file_get_contents like

if( strpos(file_get_contents("filename.txt"), $string) !== false) {         // stuff   } 

would fastest way


Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -