开发者

preg_match parsing html tags and insert into variable

开发者 https://www.devze.com 2023-03-24 12:58 出处:网络
I have the following tags and I want to extract buying and selling price: 2.9450 and 3.0150 <tr bgcolor=\"开发者_JAVA百科#E8EFF3\">

I have the following tags and I want to extract buying and selling price: 2.9450 and 3.0150

<tr bgcolor="开发者_JAVA百科#E8EFF3"> 
<td width="25%" align="center" valign="middle" class="tx11"> 
USD</td> 
<td width="8%" class="tx11">RON </td> 
<td align="right" class="tx11"> 
**2.9450**</td> 
<td width="8%" align="left" class="tx11"></td> 
<td align="right" class="tx11"> 
**3.0150**</td> 
<td width="8%" align="left" class="tx11"></td> 
<td align="right" class="tx11"> 
**2.9249**</td> 
</tr> 
  1. can anyone help me with the pattern for the values please?
  2. how can I extract the values into variables? thank you


preg_match_all( '/\*\*(.+?)\*\*/s', $str, $matches );

$matches[1][0] and $matches[1][1] will contain the two number you want.

0

精彩评论

暂无评论...
验证码 换一张
取 消