PHP Find String in CSV file

后端 未结 6 1152
无人及你
无人及你 2020-12-17 17:36

I\'ve got a large flat file of usernames and emails in the following format:

\"username\", \"email\"
\"username\", \"email\"
\"username\", \"email\"
<         


        
6条回答
  •  [愿得一人]
    2020-12-17 17:44

    I truly believe that all examples in other answers works!
    But all they are slow, because all of them travers each line in csv file...
    I have another example how to find desired string:

    $command = sprintf("grep '%s,%s' -Er %s", $userName, $email, $file);
    $result = `$command`;
    

    Yes it some kind of dark matter, but it really works and it really fast!

提交回复
热议问题