3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function getSimilarSubstring($a, $b) { if(!strlen($a) || !strlen($b)) { return ''; } if(false!==strpos($a, $b)) { return $b; } $length = strlen($b); for($i=$length-1; $i>0; $i--) { for($j=0; $j<$length-$i; $j++) { if($result = getSimilarSubstring($a, substr($b, $j, $i))) { return $result; } } } return ''; } //$word_a = "superman"; //$word_b = "stermastein"; $word_a = 'afk'; $word_b = 'fk'; var_dump(getSimilarSubstring($a, $b));
Output for 5.0.4 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
Notice: Undefined variable: a in /in/U0ejN on line 33 Notice: Undefined variable: b in /in/U0ejN on line 33 string(0) ""
Output for 4.3.0 - 5.0.3
Notice: Undefined variable: a in /in/U0ejN on line 33 Notice: Undefined variable: b in /in/U0ejN on line 33 string(0) ""