$arr = array(1, 2, 6.1, 6.2, 6.3, 6.4, 6.5)
$arr = array(1, 2, 6.1-6.5)
$array = [ 1, 2, 6.1, 6.2, 6.3, 6.4, 6.5, 7, 8 ];
$result = [ ];
for( $i = 0, $size = count( $array ); $i < $size; $i ++ ) {
$start = $array[ $i ];
$end = $start;
while( isset( $array[ $i + 1 ] ) && ! bccomp( $array[ $i + 1 ] - $array[ $i ], 0.1, 1 ) ) {
$end = $array[ ++ $i ];
}
$result[] = $start == $end ? $start : $start . '-' . $end;
}
print_r( $result );
/*
Array
(
[0] => 1
[1] => 2
[2] => 6.1-6.5
[3] => 7
[4] => 8
)
*/