0

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?

1 Answer 1

3

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);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.