one method to implement this is by while-loop and if-then-else conditions.
pass the values start and end of string to the function , other variables used below can be declared locally in the function.
$current = $start;
$string = ''; #to return this value
while ( $current <= $target )
begin
$string = $string || $current;
$current = $current + 1;
end
return the value from $string
hope this helps !