Jump to content

extracting some digits in a medium long string [with mechanize[


dilbertone

Recommended Posts

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.