<tfoot id='nOwgM'></tfoot>
<i id='nOwgM'><tr id='nOwgM'><dt id='nOwgM'><q id='nOwgM'><span id='nOwgM'><b id='nOwgM'><form id='nOwgM'><ins id='nOwgM'></ins><ul id='nOwgM'></ul><sub id='nOwgM'></sub></form><legend id='nOwgM'></legend><bdo id='nOwgM'><pre id='nOwgM'><center id='nOwgM'></center></pre></bdo></b><th id='nOwgM'></th></span></q></dt></tr></i><div id='nOwgM'><tfoot id='nOwgM'></tfoot><dl id='nOwgM'><fieldset id='nOwgM'></fieldset></dl></div>
        <bdo id='nOwgM'></bdo><ul id='nOwgM'></ul>
      <legend id='nOwgM'><style id='nOwgM'><dir id='nOwgM'><q id='nOwgM'></q></dir></style></legend>

      <small id='nOwgM'></small><noframes id='nOwgM'>

    1. PHP 从数字字符串中删除逗号

      时间:2023-05-21
      <legend id='sc7WX'><style id='sc7WX'><dir id='sc7WX'><q id='sc7WX'></q></dir></style></legend>
        <bdo id='sc7WX'></bdo><ul id='sc7WX'></ul>

        <tfoot id='sc7WX'></tfoot>

                <tbody id='sc7WX'></tbody>

              1. <small id='sc7WX'></small><noframes id='sc7WX'>

                <i id='sc7WX'><tr id='sc7WX'><dt id='sc7WX'><q id='sc7WX'><span id='sc7WX'><b id='sc7WX'><form id='sc7WX'><ins id='sc7WX'></ins><ul id='sc7WX'></ul><sub id='sc7WX'></sub></form><legend id='sc7WX'></legend><bdo id='sc7WX'><pre id='sc7WX'><center id='sc7WX'></center></pre></bdo></b><th id='sc7WX'></th></span></q></dt></tr></i><div id='sc7WX'><tfoot id='sc7WX'></tfoot><dl id='sc7WX'><fieldset id='sc7WX'></fieldset></dl></div>
                本文介绍了PHP 从数字字符串中删除逗号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                限时送ChatGPT账号..

                在 PHP 中,我有一个变量数组,它们都是字符串.一些存储的值是带逗号的数字字符串.

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

                我需要什么:

                一种从字符串中修剪逗号的方法,并且仅对数字字符串执行此操作.这并不像看起来那么简单.主要原因是以下失败:

                A way to trim the commas from strings, and ONLY do this for numeric strings. This isn't as straightforward as it looks. The main reason is that the following fails:

                $a = "1,435";
                
                if(is_numeric($a))
                    $a = str_replace(',', '', $a);
                

                这失败了,因为 $a = "1435" 是数字.但是 $a = "1,435" 不是数字.因为我得到的一些字符串将是带逗号的常规句子,所以我无法对每个字符串运行字符串替换.

                This fails because $a = "1435" is numeric. But $a = "1,435" is not numeric. Because some of the strings I get will be regular sentences with commas, I can't run a string replace on every string.

                推荐答案

                未测试,但可能类似于 if(preg_match("/^[0-9,]+$/", $a)) $a = str_replace(...)

                Not tested, but probably something like if(preg_match("/^[0-9,]+$/", $a)) $a = str_replace(...)

                这篇关于PHP 从数字字符串中删除逗号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:通过 php dom 在 html 片段中通过超链接查找和替换 下一篇:PHP 多字节 str_replace?

                相关文章

                最新文章

                      <bdo id='uS5MZ'></bdo><ul id='uS5MZ'></ul>
                    <i id='uS5MZ'><tr id='uS5MZ'><dt id='uS5MZ'><q id='uS5MZ'><span id='uS5MZ'><b id='uS5MZ'><form id='uS5MZ'><ins id='uS5MZ'></ins><ul id='uS5MZ'></ul><sub id='uS5MZ'></sub></form><legend id='uS5MZ'></legend><bdo id='uS5MZ'><pre id='uS5MZ'><center id='uS5MZ'></center></pre></bdo></b><th id='uS5MZ'></th></span></q></dt></tr></i><div id='uS5MZ'><tfoot id='uS5MZ'></tfoot><dl id='uS5MZ'><fieldset id='uS5MZ'></fieldset></dl></div>

                  1. <small id='uS5MZ'></small><noframes id='uS5MZ'>

                    <tfoot id='uS5MZ'></tfoot><legend id='uS5MZ'><style id='uS5MZ'><dir id='uS5MZ'><q id='uS5MZ'></q></dir></style></legend>