3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string = "Fasd-2"; $sub=substr($string, strrpos($string, "-")+1, strlen($string) - strrpos($string, "-")); if (is_numeric($sub)) { echo substr($string, 0, strlen($string) - strlen($sub)) . "\n"; $newString = substr($string, 0, strlen($string) - strlen($sub)) . " - " . (int)$sub+1; } else { $newString = $string . "-1"; } echo $newString;
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
Fasd- Fasd- - 3
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 Fasd- Fasd- - 3
Output for 7.4.0 - 7.4.33
Deprecated: The behavior of unparenthesized expressions containing both '.' and '+'/'-' will change in PHP 8: '+'/'-' will take a higher precedence in /in/fUd8J on line 8 Fasd- Warning: A non-numeric value encountered in /in/fUd8J on line 8 1
Output for 7.1.0 - 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33
Fasd- Warning: A non-numeric value encountered in /in/fUd8J on line 8 1
Output for 5.5.0 - 5.5.38, 5.6.0 - 5.6.38, 7.0.0 - 7.0.33
Fasd- 1

preferences:
190.37 ms | 402 KiB | 293 Q