Php Add Number To The Existing Name

[Solved] Php Add Number To The Existing Name | Php - Code Explorer | yomemimo.com
Question : php add number to the existing name

Answered by : indian-gooner

$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

Source : https://stackoverflow.com/questions/4498886/how-do-i-put-extra-number-at-the-end-of-username-if-duplicate | Last Update : Thu, 01 Oct 20

Answers related to php add number to the existing name

Code Explorer Popular Question For Php