Forum Moderators: coopster
-----------------------
Ship To:
Customer Name
123 Main St
Anytown
CA
12345
US
Number of Packages
----------------------
What I have so far:
preg_match('/Ship To:+([^Number]+)/s', $page_contents, $match_array);
$ShipTo = $match_array[1];
works but on the off chance someone uses something like
123 Main st, Number 2
In their address it will stop prematurely, second issue is that I would like to keep the line breaks in the variable, as it stands now they are being replaced with spaces.
William.
Instead of using regex, how about using either file [uk2.php.net] or file_get_contents [uk2.php.net] functions? The first would probably be best as this reads the contents of your file into an array. You can then just access the data you need.
dc