3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $string = "[vc_tab [vc_tab [vc_tab [vc_tab [vc_tab [vc_tab"; $active = 3; $needle = "[vc_tab"; $replace = '[vc_tab active="true"'; if( substr_count( $string, $needle) < $active) { throw new Exception("There aren't enough needles in the string to do this replacement"); } $count = 0; $index = 0; while( $count++ < $active) { $index = strpos( $string, $needle, $index) + ; } $result = substr( $string, $index - strlen( $needle)) . $replace . substr( $string, $index); echo "Index: ", $index, " ", $result;
Output for 5.3.0 - 5.5.1
Parse error: syntax error, unexpected ';' in /in/4kM9W on line 14
Process exited with code 255.