variables add number php code example
Example: php add number to the existing name
$name = 'foo';
$first_name = $name;
$i = 0;
do {
//Check in the database here
$exists = exists_in_database($name);
if($exists) {
$i++;
$name = $first_name . $i;
}
}while($exists);
//save $name