3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $str = 'thing_1'; $pieces = explode('_', $str); $suffix = array_pop($pieces); if ($str == $suffix) { $pieces[] = 1; } else { (int) $suffix; $pieces[count($pieces - 1)] = $suffix + 1; } $new_str = implode('_', $pieces);
based on QGAoZ
Output for 7.0.0 - 7.3.0rc4
Fatal error: Uncaught Error: Unsupported operand types in /in/0A0eo:12 Stack trace: #0 {main} thrown in /in/0A0eo on line 12
Process exited with code 255.
Output for 5.3.20 - 5.6.28
Fatal error: Unsupported operand types in /in/0A0eo on line 12
Process exited with code 255.