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 Link to comment https://forums.phpfreaks.com/topic/220489-extracting-some-digits-in-a-medium-long-string-with-mechanize/ 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]); Link to comment https://forums.phpfreaks.com/topic/220489-extracting-some-digits-in-a-medium-long-string-with-mechanize/#findComment-1142339 Share on other sites More sharing options...
AbraCadaver Posted December 2, 2010 Share Posted December 2, 2010 Typo: print_r($matches[0]); Link to comment https://forums.phpfreaks.com/topic/220489-extracting-some-digits-in-a-medium-long-string-with-mechanize/#findComment-1142354 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 Link to comment https://forums.phpfreaks.com/topic/220489-extracting-some-digits-in-a-medium-long-string-with-mechanize/#findComment-1142364 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.