如在“Your Current Quantity Discount\n\n 1 items @ $2.50 * 0% = $1.00\n\n\nTotal Discount: $2.20”取出2.50和1.00和2.20.

解决方案 »

  1.   

    $str = "Your Current Quantity Discount\n\n 1 items @ $2.50 * 0% = $1.00\n\n\nTotal Discount: $2.20”";
    preg_match_all("/([\d\.\$]+)/i",$str,$matches);
    var_dump($matches);
      

  2.   

    <?php $str = "Your Current Quantity Discount\n\n 1 items @ $2.50 * 0% = $1.00\n\n\nTotal Discount: $2.20”";preg_match_all("/(\d+\.?\d+)/i",$str,$matches);echo '<pre>';var_dump($matches);echo '</pre>'?>
      

  3.   

    <?php $str = "Your Current Quantity Discount\n\n 1 items @ $2.50 * 0% = $1.00\n\n\nTotal Discount: $2.20”";preg_match_all('/\$(\d+\.?\d+)/i',$str,$matches);echo '<pre>';var_dump($matches);echo '</pre>'?>
      

  4.   

    [code=PHP
    $str = "Your Current Quantity Discount\n\n 1 items @ $2.50 * 0% = $1.00\n\n\nTotal Discount: $2.20”";
    preg_match_all("/(\d+\.\d+)/i",$str,$matches);
    var_dump($matches);][/code]
    只要数字。自己想出来了。不过还是谢谢热心的人