PHP remove commas from numeric strings

前端 未结 7 1438
悲哀的现实
悲哀的现实 2020-11-30 12:21

In PHP, I have an array of variables that are ALL strings. Some of the values stored are numeric strings with commas.

What I need:

A way to trim the comma

相关标签:
7条回答
  • 2020-11-30 13:02
     function cleanData($a) {
    
         if(is_numeric($a)) {
    
         $a = preg_replace('/[^0-9,]/s', '', $a);
         }
    
         return $a;
    
    }
    
    0 讨论(0)
提交回复
热议问题