<?php function test($a,$b,$ret=2) { for ($i = 0; $i < max(strlen($a),strlen($b)) && $ret > 0; $i++) if (strcmp($a[$i],$b[$i]) !== 0) $ret--; return $ret;} echo test("abc","abc") . PHP_EOL; // 2echo test("abc","abd") . PHP_EOL; // 1echo test("abc","add") . PHP_EOL; // 0echo test("abc","XXX") . PHP_EOL; // 0echo test("abcde","abc") . PHP_EOL; // 0echo test("abcd","abc") . PHP_EOL; // 1
Standard input is empty
2 1 0 0 0 1
PHP Notice: Uninitialized string offset: 3 in /home/jcqGl6/prog.php on line 5 PHP Notice: Uninitialized string offset: 4 in /home/jcqGl6/prog.php on line 5 PHP Notice: Uninitialized string offset: 3 in /home/jcqGl6/prog.php on line 5
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!