Ok so I have documents containing specific data I would like to sort into a database. The bit I'm now having trouble with is pulling the data from the string. For example: $string = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec sit amet: 7899942378 Nunc ornare nulla in quam tempus sed"; The number of lines before and after the data (in green) varies doc to doc, however "Donec sit amet: " before the data will always remain the same*, so I need to find the line containing "Donec sit amet: " then take what is left until the end of the line. EDIT: The length of the data also changes, e.g sometimes it's +1 or -1 the usual length. *Actually there is some variation, but not a lot so I was going to either change it manually when I need to, or throw in an if statement. I did try searching for this but couldn't come up with anything. Thanks, Scot
<?php $string = " Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec sit amet: 7899942378 Nunc ornare nulla in quam tempus sed"; preg_match("#Donec sit amet: (.*?)\r\n#i",$string,$matches); echo $matches[1]; ?> PHP: