iT邦幫忙

0

PHP preg_match 擷取語法; 從字串$st_data中擷取"nowrap>"後面的數字58

  • 分享至 

  • twitterImage

$st_data=<font color=#000000>0.00 <td align="center" bgcolor="#FFFfff" nowrap>58;
//從字串$st_data中抓出"<td align="center" bgcolor="#FFFfff" nowrap>"後面的數字58
preg_match("/nowrap>(.*)/si",$st_data,$match);
print_r($match[1]);

//"/nowrap>(.*)/si"這樣的寫法無法找到58,還請先進指導正確的寫法。

圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

1 個回答

0
海綿寶寶
iT邦大神 1 級 ‧ 2020-07-31 08:40:31
最佳解答

參考看看

$str = "<font color=#000000>0.00 <td align=\"center\" bgcolor=\"#FFFfff\" nowrap>58";
if (preg_match("/nowrap>.*/m", $str, $arr)) {
    echo substr($arr[0],strpos($arr[0],">")+1) . "\n";
}

我要發表回答

立即登入回答