Decrement character with php

前端 未结 5 990
盖世英雄少女心
盖世英雄少女心 2021-01-12 01:15

Why is it that it\'s ok to increment character but not decrement with PHP?

PHP



        
5条回答
  •  半阙折子戏
    2021-01-12 01:36

    There is no direct way to decrement alphabets. But with a simple function you can achieve it:

    function decrementLetter($Alphabet) {
        return chr(ord($Alphabet) - 1);
    }
    

    Source, thanks to Ryan O'Hara

提交回复
热议问题