Search code examples
phpcurlstripping

Grab within from Curl


I curl and get the following:

echo $contents

which gives me this:

 <td class="fomeB1" >Balance: $ 1.02</td>

$13.32 fee
$15.22 fee 2

How do I just grab the 1.02 - everything after the $ and in front of the </td>

I want to strip this via php and put the money into variable $balance....

Any kind of help I can get on this is greatly appreciated!


Solution

  • yes you can use exactly what u want

    preg_match("/(?<=Balance: ).*?(?=<)/", "<td class='fomeB1'>Balance: $ 1.02</td>", $match);
    print_r(str_replace("$"," ",$match));
    
    // Prints:
    Array
    (
        [0] =>   1.02
    )