preg_replace替换属性中为null

I built a google currency converter,but i didn't understand this part of code

$converted_amount = preg_replace("/[^0-9\.]/", null, $get[0]);

what is the job of this pattern,and what is null means here?

full code:

$amount = urlencode($_POST['amount']);
            $from_Currency = urlencode($_POST['from']);
            $to_Currency = urlencode($_POST['to']);
            $get = file_get_contents("https://www.google.com/finance/converter?a=$amount&from=$from_Currency&to=$to_Currency");
            $get = explode("<span class=bld>",$get);
            $get = explode("</span>",$get[1]);
            print_r($get);
            $converted_amount = preg_replace("/[^0-9\.]/", null, $get[0]);

[^0-9\.] means any character but digits 0123456789 and .. This will only match one character. null means replace with an empty string, delete it in other words. Next time you can do a simple search on Google and find the same information.

While what Nicolas Maltais wrote is basically true, it is a bit unclear.

  • [^0-9\.] … will only match one character. - True, however, preg_replace replaces all the matches, since there's no limit specified, thus removing all other characters from the string.
  • null means replace with an empty string - seems true, however, is not documented in the preg_replace manual. Only after quite some searching I found hints on the Strings page, section Converting to string:

    String conversion is automatically done in the scope of an expression where a string is needed. … NULL is always converted to an empty string.