3v4l.org

run code in 300+ PHP versions simultaneously
<?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));

preferences:
37.44 ms | 402 KiB | 5 Q