title: Generate shorted unique username based on array of first names and last names
body: <p>I have a multi-dimensional array called users that is formatted like the following and I am trying to create a script that will create a &quot;username&quot; based on this information:</p>
  <pre><code>$users = [
      ['first_name' =&gt; 'Bob', 'last_name' =&gt; 'Smith'],
      ['first_name' =&gt; 'Steve', 'last_name' =&gt; 'Little'],
      ['first_name' =&gt; 'Eric', 'last_name' =&gt; 'Fielder'],
      ['first_name' =&gt; 'Steve', 'last_name' =&gt; 'Richardson'],
      ['first_name' =&gt; 'Bob', 'last_name' =&gt; 'Sanders'],
      ['first_name' =&gt; 'Bob', 'last_name' =&gt; 'Sanders'],
      ['first_name' =&gt; 'Bob', 'last_name' =&gt; 'Smith'],
  ];
  </code></pre>
  <p>Required Logic:</p>
  <ul>
  <li><p>If there are no duplicate first names it uses only the first name as the username
  (&quot;<strong>Eric</strong>&quot;).</p>
  </li>
  <li><p>If there are two names with the same first but different initial letters in the last name it will use the first name as last initial (&quot;<strong>Steve L.</strong>&quot; and &quot;<strong>Steve R.</strong>&quot;).</p>
  </li>
  <li><p>If multiple people have the last first name and last initial then it return the full name (&quot;<strong>Bob Smith</strong>&quot; and &quot;<strong>Bob Sanders</strong>&quot;).</p>
  </li>
  <li><p>Lastly, if the SAME exact name is found then it will append a number to each like this: &quot;Bob <strong>Sanders (1)</strong>&quot; and &quot;<strong>Bob Sanders (2)</strong>&quot;</p>
  </li>
  </ul>
  <p>I am hoping this can be done efficiently and not with a lot of loops, but I can not figure it out for the life of me.</p>