title: PHP: If number (with comma), convert it to right number format (with point)
body: <p>I have an array of mixed values:</p>
  
  <pre><code>$row = array('Unspecified risk','Yes','8','3','2','13','none','-1,49','-2,51','-1,46','-1,54'); -1,94   -1,55
  </code></pre>
  
  <p>As you can see it contains text and both negative and positive comma-numbers.</p>
  
  <p>I need to convert the numeric values to the right number format and leave the text values as is. </p>
  
  <p>Now I'm looping over the values:</p>
  
  <pre><code>foreach ($row as $value) {
      // If $value is numeric, convert it to the 
      // right number format for use with MySQL (decimal(10,2))
      // If not, leave it be.
  }
  </code></pre>
  
  <p>Two related questions I've investigated but cannot find a suitable solution.</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/4325363/converting-a-number-with-comma-as-decimal-point-to-float">Converting a number with comma as decimal point to float</a></li>
  <li><a href="https://stackoverflow.com/questions/6994704/i-need-php-regular-expression-for-numeric-value-including-and?lq=1">I need php regular expression for numeric value including &quot;-&quot; and &quot;,&quot;</a></li>
  </ul>
  
  <p>Could anyone provide a practical example?</p>