dilbertone Posted December 2, 2010 Share Posted December 2, 2010 hi there - hello dear PHP-Friends, good evening! - i want to extract some data ouf of a large html-file. i have - a very very large amount of data: approx 5000 x the following line-sheme!: 67003 Cato Bontjes Vice Versum House 1 28832 Achim 62042 Cato Bontjes Vice Versum House 2 28832 Achim 41798 Cato Bontjes Vice Versum House 3 37139 Adelebsen 40034 Cato Bontjes Vice Versum House 4 21365 Adendorf 46218 Cato Bontjes Vice Versum House 5 31855 Aerzen 42481Cato Bontjes Vice Versum House 6 21702 Ahlerstedt 49761 Cato Bontjes Vice Versum House 7 26197 Ahlhorn Question: how can i extract the first 5 first digits...!? I have allready some solutions here - i need a very very robuste solution diblertone1 Quote Link to comment Share on other sites More sharing options...
AbraCadaver Posted December 2, 2010 Share Posted December 2, 2010 Not tested, but should work: $lines = file('/path/to/file.html'); foreach($lines as &$line) { $values = explode(' ', $line); $line = $values[0]; } print_r($lines); Or this: preg_match_all('/^[\d]{5}/m', file_get_contents('/path/to/file.html'), $matches); print_r($matches[]0]); Quote Link to comment Share on other sites More sharing options...
AbraCadaver Posted December 2, 2010 Share Posted December 2, 2010 Typo: print_r($matches[0]); Quote Link to comment Share on other sites More sharing options...
dilbertone Posted December 2, 2010 Author Share Posted December 2, 2010 Hi there - hello AbraCadaver - good evening! Great that you have answered. Typo: print_r($matches[0]); i will have a closer look. Many Thanks many Greetings dilbertone 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.