xcislav Posted April 8, 2015 Share Posted April 8, 2015 editor.php: <form action="somesense.php" ... j=new XMLHttpRequest(); j.open("POST","updatenine.php" ... j.open("GET","lb.php? IN RESULT: (editor.php contains) somesense.php updatenine.php lb.php For example, all three files one by one have been being put into array by echoing it with strpos (from that large variable). When searching is under way and strpos comes with it's results ".php" it adds all letters/numbers (until some other leading character). For example for the first strpos finds: "lb.php? .php and adds lb, finishing with lb.php , cutting " and ? from the found line (from code). It cuts " and ? because those symbols aren't proper file names. ----- ----- First found Find pathnames matching a pattern - http://php.net/globwith it's array glob(string pattern [, int flags]) Seems to have some limits, imposed on the forms of representation. I would intend to search within large files. from php's man: The glob() function searches for all the pathnames matching pattern according to the rules used by the libc glob() function, which is similar to the rules used by common shells. "common shells" aren't the best choice for the large-scaled searches. What would you recommend? Quote Link to comment Share on other sites More sharing options...
IThinkMyBrainHurts Posted April 8, 2015 Share Posted April 8, 2015 Glob searches filenames within the current directory... it doesn't search within a file...??? Why strpos, why not use preg_grep? (simpler, better results, can do all at once, but maybe slightly slower) As for common shells... nothing wrong with them since most applications are written in C, e.g. glob. Can you simplify your question? Are you just wanting to know to best (fastest or memory efficient) way to search files? Should the search be optimised for memory or speed? Quote Link to comment Share on other sites More sharing options...
QuickOldCar Posted April 8, 2015 Share Posted April 8, 2015 What would you recommend? Using a database and not hunting directories and files. I would intend to search within large files. Yes for sure a database. One major downfall is no matter how little the data is you want to fetch from a file...the entire file has to be loaded regardless. Quote Link to comment Share on other sites More sharing options...
IThinkMyBrainHurts Posted April 8, 2015 Share Posted April 8, 2015 One major downfall is no matter how little the data is you want to fetch from a file...the entire file has to be loaded regardless. Not with fseek: http://php.net/manual/en/function.fseek.php Quote Link to comment Share on other sites More sharing options...
xcislav Posted April 9, 2015 Author Share Posted April 9, 2015 (edited) Why strpos, why not use preg_grep? (simpler, better results, can do all at once, but maybe slightly slower) Because I can't imagine an array of program source. What type of "chunks" of this array could you imagine when it's just a source code... Edited April 9, 2015 by xcislav Quote Link to comment 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.