从Perl转换为PHP

sub numeric_p {
    local($data) = @_;
    if ($data =~ /^-?\d*\.?\d*(e\d|e-\d)?\d*$/) {
        $true;
    } else {
        $false;
    };
}

How can I translate this piece of code to PHP? The only piece I can't translate is the piece on the 3rd line, starting with if.

How can I do that?

This is a test if $data matches the following regular expression. It just becomes a call to preg_match() in PHP:

// In Perl
if ($data =~ /^-?\d*\.?\d*(e\d|e-\d)?\d*$/) 

// In PHP:
if (preg_match('/^-?\d*\.?\d*(e\d|e-\d)?\d*$/', $data))

PHP's preg_match function serves the same purpose as Perl's =~ operator.