3v4l.org - online PHP & HHVM shell, execute code in 100+ different versions!

<?php $strings = array( '100010' => '110', '010200' => '1200', '01110' => '1110', ); foreach ($strings as $subject => $expected) { $actual = preg_replace('/0+(?!$|0)/', '', $subject); printf(" %s -> %s (expected: %s)\n", $subject, $actual, $expected); }
Output for 4.3.0 - 5.6.0, php7@20140507 - 20140901, hhvm-3.0.1 - 3.2.0
100010 -> 110 (expected: 110) 010200 -> 1200 (expected: 1200) 01110 -> 1110 (expected: 1110)