increment_string()

increment_string($str[, $separator = '_'[, $first = 1]])

Parameters:
  • $str (string) – Input string
  • $separator (string) – Separator to append a duplicate number with
  • $first (int) – Starting number
Returns:

An incremented string

Return type:

string

Increments a string by appending a number to it or increasing the number. Useful for creating “copies” or a file or duplicating database content which has unique titles or slugs.

Usage example:

echo increment_string('file', '_'); // "file_1"
echo increment_string('file', '-', 2); // "file-2"
echo increment_string('file_4'); // "file_5"
doc_CodeIgniter
2016-10-15 16:32:26
Comments
Leave a Comment

Please login to continue.