<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                ### PHP入門小菜鳥一枚。下午要求寫一個把數字轉成大寫中文的腳本,百度了一波,幾十個博客和網站都是用的那四個代碼,第一個運行不了,第二個有問題,不合要求,第三個第四個太長,懶得看,只好自己寫個,部分代碼抄別的,那么多博客相同的代碼,我也不知道來源是誰。要去大概這樣。 ~~~ 1. 120002129.25 轉化后 壹億貳仟萬貳仟壹佰貳拾玖圓貳角伍分 2. 12000.2145 轉化后 壹萬貳仟圓貳角壹分肆厘伍毫 3. 1020001211 轉化后 壹拾億貳仟萬壹仟貳佰壹拾壹圓整 ~~~ ### 大致思路這樣的: 1. 從小數點分割成兩部分,整數部分和小數部分分別處理。 2. 整數四個一組進行處理,用substr函數分組,然后循環加上萬和億。 3. 把多余的零刪除掉。 4. 小數部分遍歷匹配相應的單位。 代碼寫出來了,剛剛發現了個bug,暫時不想改,就是這么任性。感覺還有優化的地方。我看到最短的代碼只有20多行,雖然我運行不了,思路也不一樣。 代碼如下: ~~~ <?php function to_upcase_chinese($num){ $digitArr1 = [1 => '',2 => '拾',3 => '佰',4 => '仟']; $Array = [0 => '',1 => '萬', 2 => '億']; $intArr = ['零','壹','貳','叁','肆','伍','陸','柒','捌','玖']; $decimalArr = [0 => '角',1 => '分',2 => '厘',3 => '毫']; $int = null; $decimal = null; if (false !== strpos($num,'.')) { $spreator = explode('.',$num); $int = reset($spreator); $decimal = end($spreator); } else { $int = (string)$num; } $combine = ''; $residue = floor((strlen($int) / 4)); $mol = strlen($int) % 4; for($b = $residue + 1; $b >= 1; ){ $length = $b == ($residue + 1) ? $mol : 4; $b--; $st = substr($int,($b * (-4)) - 4, $length); if($st !== ''){ for ($a = 0; $a < strlen($st); $a++) { if (intval($st[$a]) === 0) { $combine .= '零'; } else{ $combine .= $intArr[intval($st[$a])].$digitArr1[strlen($st)-$a]; } } $combine .= $Array[$b]; } } $combine1 = ''; if ($decimal !== null || intval($decimal) !== 0 || strlen($decimal) !== 0) { for ($i=0; $i < (strlen($decimal) < 4 ? strlen($decimal): 4); $i++) { if (intval($decimal[$i]) === 0) { $combine1 .= ''; } else { $combine1 .= $intArr[intval($decimal[$i])].$decimalArr[$i]; } } }else{ $combine1 .= '整'; } $combine = $combine.'圓'.$combine1; var_dump('悄悄寫個dump,現在博客園叫被水淹死的大白鯊') $j = 0; $slen = strlen($combine); while ($j < $slen) { $m = substr($combine, $j, 6); if ($m == '零圓' || $m == '零萬' || $m == '零億' || $m == '零零') { $left = substr($combine, 0, $j); $right = substr($combine, $j + 3); $combine = $left . $right; $j = $j-3; $slen = $slen-3; } $j = $j + 3; } return $combine; } ~~~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看