Convert a number to its string representation

前端 未结 4 1715
野性不改
野性不改 2021-01-13 21:53

I\'m developing a simple web application where in I need to display number a to my users in string format.

Example:

12 - One Two or Twelve
-20 - min         


        
4条回答
  •  借酒劲吻你
    2021-01-13 22:39

    for the first option (spell out digits), strtr is your friend

    $words = array(
      '-' => 'minus ',
      '1'  => 'one ',
      '2' => 'two ',
    etc....
    );
    
    echo strtr(-123, $words);
    

提交回复
热议问题