3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $default = array( 'Year', 'Mining-1969-70=100', 'Mining-1975-76=100', 'Man-1980-81=100', 'Man-198081=100', ); $default2 = array( 'Year', 'Mining-1969-70=100', 'Mining-1975-76=100', 'Mining-1980-81=100', 'Man-198081=100', ); function getFollowingSimilarValues($arr, $start) { $count = count($arr); if ($start >= $count) return array(); $result = array($arr[$start]); $strpos = strpos($arr[$start],'-'); for ($i=($start+1); $i<$count; $i++) { if (strncasecmp($arr[$start], $arr[$i], $strpos) == 0) $result[] = $arr[$i]; } return $result; } print implode(", ", getFollowingSimilarValues($default, 1))."<br>"; print implode(", ", getFollowingSimilarValues($default2, 1));
Output for 4.3.0 - 7.2.0
Mining-1969-70=100, Mining-1975-76=100<br>Mining-1969-70=100, Mining-1975-76=100, Mining-1980-81=100