Decrement character with php

前端 未结 5 948
盖世英雄少女心
盖世英雄少女心 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:45

    Please try with this. Output is a b a.

    $a = "a";
    echo $a. "
    "; echo $next = chr(ord($a) + 1). "
    "; echo $prev = chr(ord($next) - 1 ). "
    ";

提交回复
热议问题