如何使用PHP从字符串中获取某些特定数据?

I have three string as like below. I can get one string at a time from a sports website, the string format might be in 3 different ways or it could be any other way. But the string must have the same information.

(all out; 71.2 overs; 291 mins)
(all out; 129.1 overs)
(5 wickets dec; 97 overs)

I wanted to extract below data from those string using PHP. How can I do it?

$wicket = 10; //if all out
$over = 71;
$ball = 2; //it will be 0 if over doesn't have floating number

I believe you are wanting to use the stristr() function. This will search a string for a proved string.

Convert the JSON to an array and loop to populate $providedString below.

$dataFromSomewhere = /* ... */;
$returnValue =0

foreach ($dataFromSomeWhere as $key => $value) {
    echo $value; # would be, for exp: `(5 wickets dec; 97 overs)`

    if (stristr($value, 'wickets')) {
        $returnValue += 10;
    } elseif (stristr($value, 'overs')) {
        $returnValue += 5;
    }
}
echo $returnValue; # would be, for exp: 15

As for $ball check the score value for the . or try to cast as a decimal/double and check if it does (boolean check).