3v4l.org

run code in 300+ PHP versions simultaneously
<?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++) { //echo(sprintf('Current[%s][%s] = %s'.PHP_EOL, $i, $j, substr($b, $j, $i))); if(false!==strpos($a, $result = substr($b, $j, $i))) { return $result; } } } return ''; } $word_a = "superman"; $word_b = "stermastein"; //$word_a = 'afk'; //$word_b = 'fk'; var_dump(getSimilarSubstring($word_a, $word_b));
Output for git.master, git.master_jit, rfc.property-hooks
string(4) "erma"

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
37.02 ms | 401 KiB | 8 Q