<?php $strings = array( '100010' => '110', '010200' => '1200', '01110' => '1110', ); foreach ($strings as $subject => $expected) { $actual = preg_replace('/(?>0+)(?!$)/', '', $subject); printf(" %s -> %s (expected: %s)\n", $subject, $actual, $expected); }
You have javascript disabled. You will not be able to edit any code.