如何使用preg_match从给定的字符串中找出数字?

if (
  preg_match("/^bundle id/", trim($rows[$key])) && 
  preg_match('/\d/', trim($rows[$key]), $temp))

.

bundle id 1 mode active
bundle id 99 mode active
bundle id 999 mode active

how to find out 1,99 and 999 in given preg_match expression.

Your second preg_match needs to become preg_match_all, and the regex needs to look for \d+, which is one or more numerical digits:

preg_match_all('/\d+/', trim($rows[$key]), $temp))

$temp will now contain an array of values:

array (size=1)
  0 => 
    array (size=3)
      0 => string '1' (length=1)
      1 => string '99' (length=2)
      2 => string '999' (length=3)

Edit

The above answer was on the basis that the sample string is one line.

If each line represents a different string, then all you need to do is alter the regex to\d+:

if(preg_match("/^bundle id/", trim($rows[$key])) && 
    preg_match('/\d+/', trim($rows[$key]), $temp))

I'd do:

preg_match("/^bundle id\s*(\d+)/", trim($rows[$key]), $match)

Then the results are in $match[1]