php實作月份數字轉英文的方法:先建立一個PHP範例檔案;然後透過「public function Month_E($Num){...}」方法將數字轉換為英文月份即可。
本文操作環境:windows7系統、PHP7.1版,DELL G3電腦
將目前數位月份轉換為英文月份
此函數實作將數字轉換為英文月份
<?php class Num_Chinese{ private $Month_E = array(1 => "January", 2 => "February", 3 => "March", 4 => "April", 5 => "May", 6 => "June", 7 => "July", 8 => "August", 9 => "September", 10 => "October", 11 => "November", 12 => "December"); public function Month_E($Num){ return $this -> Month_E[$Num]; } } ?>
使用方法
<?php require_once("./上面类函数的页面名称"); $da = new Num_Chinese(); echo $da -> Month_E(1); ?>
推薦學習:《PHP影片教學》
以上是php怎麼實現月份數字轉英文的詳細內容。更多資訊請關注PHP中文網其他相關文章!