3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php // palindrom function anagram($s1, $s2) { $l1 = strlen($s1); $l2 = strlen($s2); if($l1 != $l2) return false; // $w1 = array(); $w2 = array(); // for($a=0; $a<$l1; $a++) { if(array_key_exists($s1[$a], $w1)) { $w1[$s1[$a]] = $w1[$s1[$a]] + 1; // print_r($s1[$a]); } else { $w1[$s1[$a]] = 1; } } // print_r($w1); for($a=0; $a<$l2; $a++) { if(array_key_exists($s2[$a], $w2)) { $w2[$s2[$a]] = $w2[$s2[$a]] + 1; print_r($s2[$a]); } else { $w2[$s2[$a]] = 1; } } ksort($w1); ksort($w2); print_r($w1); print_r($w2); print_r(array_diff(array_keys($w1), array_keys($w2))); print_r(array_diff($w1, $w2)); } echo anagram('test', 'testaaa'); //print_r(array('tesfsdf' => 'dasdsad')); ?>
Output for 4.3.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0