计算文本文件中每行中的数字,并通过php加上它们

I have a text file with multiple rows-

URL=> https://google.com/ ok=> 999 Result=> 200
URL=> https://instagram.com ok=> 999 Result=> 200

So I want to calculate all the numbers present after ok=> and before Result=>

Like there are 2 lines for example, then it should plus 999+999 = 1998 (this is the result I want to show in php)

You can use preg_match_all along with the array_sum as

preg_match_all('/(?<=(ok=>\s)).*?(?=(\sResult))/m','URL=> https://google.com/ ok=> 999 Result=> 200 URL=> https://instagram.com ok=> 999 Result=> 200',$res);
echo array_sum($res[0]);//1998

Demo