3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function getCount($str) { $vowelsCount = 0; $vowels = array('a', 'e', 'i', 'o', 'u'); $letters = str_split($str); print_r($letters); foreach ($letters as $letter) { if (in_array($letter, $vowels)) { $vowelsCount++; } } return $vowelsCount; } echo getCount('heyo'); function getMiddle($text) { $length = strlen($text); if ($length%2 == 0) { echo $length/2; return substr($text, $length/2 - 1, 2); } else { return substr($text, $length/2, 1); } } //echo getMiddle('test');
based on 9oWZZ
Output for 5.6.0 - 5.6.30, hhvm-3.18.4 - 3.21.0, 7.0.0 - 7.3.0rc3
Array ( [0] => h [1] => e [2] => y [3] => o ) 2