Base on the answer Decrementing alphabetical values
what about if i have a character like this $char='AF', how can i make it to $char='AE' and so on ?
UPDATE
Here is my complete solution:
function decrementChar($par){
if(strlen($par)>=2){
$str= substr($par,0,-1);
$strdec= substr($par,-1);
$strdec=$strdec=='A'?'':chr(ord($strdec) - 1 );
return $str.$strdec;
}
return chr(ord($par) - 1 );
}
if your string is a hex value, you can use the following code:
$char = 'AF';
$value = hexdec($char);
$value--;
$char = dechex($value);
if you string is just a string:
$len = strlen($char);
$char[$len - 1] = chr(ord($char[$len - 1]) - 1);