检查字符串是否为数字,但不包括检查中的欧元符号

I want to be able to add products with a price but also with just a text. So I build a check to see if the string is numeric. My problem is that I show the price like this:

if($product['xreference'] != ''){
    $price = '€ '.strip_tags($product['xreference']);
  }else{
    $price = '';
  }

So how can I check if $price is numeric but exclude the euro sign in the check?

Assuming you want to do is_numeric check after the written line of code in question, One way is :

$priceTest = str_replace('€', '', $price);

$result = is_numeric($priceTest);

if ($result) {
    echo " it is numeric";
}

You could check if data is numeric before adding "€" to $price variable

if($product['xreference'] != ''){

    if(is_numeric($price)){ // If data is numeric then add '€' to $price.

        $price = '€ '.strip_tags($product['xreference']);
    }
    else 
    {
        // data of $price is not numeric value
    }

}
else
{
    $price = '';
}

You can use str_replace i am posting some code may be it can help

<?php
  $price = 'dsf';
  $productPrice['xreference'] = '€'.$price;
  $onlyPrice = str_replace ("€","",$productPrice['xreference']);
  if(ctype_digit($onlyPrice)){
     echo "Yes";die;
  }else{
    echo 'not';die;
  }
?>

if $price=100; then it will be Yes