从字符串中抓住美分

I want to grab only the cents from the strings I have, not the full dollar.. anything that starts with 0.xx is what I want to echo out:

$paste = "08/29/2014    Interest Paid       $ 0.03  $ 37.69
08/25/2014  ACH Deposit         $ 0.93  $ 37.66
08/20/2014  ACH Deposit         $ 0.63  $ 36.73
08/04/2014  ACH Deposit         $ 0.95  $ 36.10
08/04/2014  ACH Deposit         $ 0.57  $ 35.15
08/04/2014  ACH Deposit         $ 0.88  $ 34.58
07/31/2014  Interest Paid       $ 0.01  $ 33.70
07/31/2014  ACH Deposit         $ 0.13  $ 33.69
07/31/2014  ACH Deposit         $ 0.96  $ 33.56
07/31/2014  ACH Deposit         $ 0.65  $ 32.60
07/31/2014  ACH Deposit         $ 0.53  $ 31.95
07/31/2014  ACH Deposit         $ 0.83  $ 31.42
07/30/2014  ACH Deposit         $ 0.63  $ 30.59
07/28/2014  ACH Deposit         $ 0.76  $ 29.96";

I have tried the following but it wouldn't do what I need it nor echo line by line of the cents i'm looking for...

$find = strpos($paste, '0.');
sscanf(substr($paste, $find), '0.%d', $numbers);

Any help I can get on this is greatly appreciated. Thank you in advance..

You could try something like this

$paste = <<<EOT
08/29/2014  Interest Paid       $ 0.03  $ 37.69
08/25/2014  ACH Deposit         $ 0.93  $ 37.66
08/20/2014  ACH Deposit         $ 0.63  $ 36.73
08/04/2014  ACH Deposit         $ 0.95  $ 36.10
08/04/2014  ACH Deposit         $ 0.57  $ 35.15
08/04/2014  ACH Deposit         $ 0.88  $ 34.58
07/31/2014  Interest Paid       $ 0.01  $ 33.70
07/31/2014  ACH Deposit         $ 0.13  $ 33.69
07/31/2014  ACH Deposit         $ 0.96  $ 33.56
07/31/2014  ACH Deposit         $ 0.65  $ 32.60 07/31/2014  ACH Deposit         $ 0.53  $ 31.95
07/31/2014  ACH Deposit         $ 0.83  $ 31.42
07/30/2014  ACH Deposit         $ 0.63  $ 30.59
07/28/2014  ACH Deposit         $ 0.76  $ 29.96
EOT;

preg_match_all('/\$\s00?\.(\d+)/', $paste, $cents);
print_r($cents[1]);

As you can see, each value doesn't have to be in each line.

Output:

Array
(
    [0] => 03
    [1] => 93
    [2] => 63
    [3] => 95
    [4] => 57
    [5] => 88
    [6] => 01
    [7] => 13
    [8] => 96
    [9] => 65
    [10] => 53
    [11] => 83
    [12] => 63
    [13] => 76
)

If you want to have the whole value like 0.03 change the pattern above to this.

\$\s(00?\.\d+)

Working PHP demo | Working Regex demo

you can try:

$matches = array();
preg_match_all('/\$ 0.[0-9]{2}  /', $paste, $matches);