ballhogjoni Posted October 10, 2007 Share Posted October 10, 2007 is there a function that will read the contents of a file and give you the ability to extract certain words out of that file. I have tried file get contents() ex. file_get_contents(file.php); or somthing like that. Quote Link to comment https://forums.phpfreaks.com/topic/72562-is-there-a-function-that-will-do-this/ Share on other sites More sharing options...
darkfreaks Posted October 10, 2007 Share Posted October 10, 2007 use file get contents to put the file into a string then use strpos to search the string and find the exact occurence of those words Quote Link to comment https://forums.phpfreaks.com/topic/72562-is-there-a-function-that-will-do-this/#findComment-365907 Share on other sites More sharing options...
darkfreaks Posted October 10, 2007 Share Posted October 10, 2007 actually i was wrong strpos will only return the first occurence of those words if you want it to return all occurences of the searched words you need to use strpbrk() instead of strpos. http://us.php.net/manual/en/function.strpbrk.php Quote Link to comment https://forums.phpfreaks.com/topic/72562-is-there-a-function-that-will-do-this/#findComment-365922 Share on other sites More sharing options...
Barand Posted October 10, 2007 Share Posted October 10, 2007 What do you mean by "extract"? Do you want to know if a word exists in the file? Do you want to know where a word exists in the file? Do you want to know how many times a word exists in the file? Do you want to remove occurences of a word from the file? Quote Link to comment https://forums.phpfreaks.com/topic/72562-is-there-a-function-that-will-do-this/#findComment-366039 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.