Reputation: 3628
I have a fairly large text file from which I need to extrapolate a string in PHP. The file in question can be accessed here. What I need taken out is the first column of the Total Public Debt Outstanding
line. It will vary from day to day, that is where I need help. The Total Public Debt Outstanding
line will always be there, how do I get preg_match
to match the text immediately following it?
Upvotes: 0
Views: 83
Reputation: 73041
The following should do it, albeit not very elegant.
$data = file_get_contents('data.txt');
preg_match('/Total\s+Public\s+Debt\s+Outstanding\s+(\S+)/', $data, $matches);
print_r($matches);
Upvotes: 3