3v4l.org

run code in 300+ PHP versions simultaneously
<?php function decrement($str) { $index = strlen($str)-1; $ord = ord($str[$index]); if ($ord > 65) { // The final character is still greater than A, decrement return substr($str, 0, $index) . chr($ord-1); } if ($index > 0) { // Strip the final 2 characters and append a Z return substr($str, 0, $index-1) . 'Z'; } // Can't be decremented return false; } var_dump( decrement('A'), decrement('AA'), decrement('AAAA'), decrement('XXXZ') );
Output for git.master, git.master_jit, rfc.property-hooks
bool(false) string(1) "Z" string(3) "AAZ" string(4) "XXXY"

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
35.2 ms | 405 KiB | 5 Q