PHP code example of newteng / format-cny
1. Go to this page and download the library: Download newteng/format-cny library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
newteng / format-cny example snippets
new \Newteng\FormatCny\Cny();
echo $c->transform('1433') . PHP_EOL; //壹仟肆佰叁拾叁圆整
echo $c->transform('0.89') . PHP_EOL; //捌角玖分
echo $c->transform('11343') . PHP_EOL; //壹万壹仟叁佰肆拾叁圆整
echo $c->transform('0.001') . PHP_EOL; //零圆整
namespace App\Http\Controllers;
use Newteng\FormatCny\Cny;
class IndexController extends Controller
{
public function index(Cny $cny)
{
// return $cny->transform(10.055); // 壹拾圆零陆分
// return $cny->transform(10.0); // 壹拾圆整
// return $cny->transform(9.995); // 壹拾圆整
// return $cny->transform(10.011); // 壹拾圆零壹分
return $cny->transform(123456789.01); // 壹亿贰仟叁佰肆拾伍万陆仟柒佰捌拾玖圆零壹分
}
}