Q:

Write a PHP script to print the next character of a specific character

0

Write a PHP script to print the next character of a specific character.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

<?php
$cha = 'a';
$next_cha = ++$cha; 
//The following if condition prevent you to go beyond 'z' or 'Z' and will reset to 'a' or 'A'.
if (strlen($next_cha) > 1) 
{
 $next_cha = $next_cha[0];
 }
echo $next_cha."\n";
?>

Sample Output:

b

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now