What is the approximate number indicated by php?

function numDisplay($num){

    if ($num >= 11 && $num <= 20){
        $str = "10+";
    }else if ($num >= 21 && $num <= 30){
        $str = "20+";
    }
    return $str;
}

this kind of manual addition seems to be too much.
is there a better way to do this? Automatically follow such rules

Apr.09,2021


function numDisplay($num = 0){
    return ($num<10)?$num:strval($num)[0].'0+';
}

-add if the length is unknown-

 function numDisplay($num = 0){
      return ($num<10)?$num:strval($num)[0].str_repeat('0',strlen($num)-1).'+';
  }
Menu