Text.php
public static function increment(string $str, int $first = 1, string $separator = '_') : string
    {
        preg_match('/(.+)'.$separator.'([0-9]+)$/', $str, $match);

        return isset($match[2]) ? $match[1].$separator.($match[2] + 1) : $str.$separator.$first;
    }
public static function increment(string $str, int $first = 1, string $separator = '_') : string
    {
        preg_match('/(.+)'.$separator.'([0-9]+)$/', $str, $match);

        return isset($match[2]) ? $match[1].$separator.($match[2] + 1) : $str.$separator.$first;
    }
public static function increment ( string $ str , int $ first = 1 , string $ separator = '_' ) : string { preg_match ( '/(.+)' . $ separator . '([0-9]+)$/' , $ str , $ match ) ; return isset ( $ match [ 2 ] ) ? $ match [ 1 ] . $ separator . ( $ match [ 2 ] + 1 ) : $ str . $ separator . $ first ; }
Add's _1 to a string or increment the ending number to allow _2, _3, etc

$str = Text::increment($str);

@param  string  $str       String to increment
@param  int     $first     Start with
@param  string  $separator Separator
@return string
Add s _1 to a string or increment the ending number to allow _2 _3 etc