title: Getting repeated values in jquery token field ,how to avoid those repeated values
body: <p>Hello everyone i am working with jquery tokenfield ,in that getting same user name multiple times so i want it should come only once below i had posted my code can you tell me how to avoid duplicate values.
  <a href="https://i.stack.imgur.com/CkBvH.png" rel="nofollow noreferrer">getting same values repeatedly</a>   </p>
  
  <p>Below code for tokenfield in script with text box. i am using codeigniter framework.</p>
  
  <pre><code>&lt;input type="text" name="txt" class="get_username"&gt;
  
  &lt;script&gt;
  function get_token_field() {
      $('.get_username').tokenfield({
          autocomplete: {
              source: "&lt;?= base_url('controller/method name') ?&gt;",
              delay: 100
          },
          showAutocompleteOnFocus: true
      });
  }
  &lt;/script&gt;
  </code></pre>
  
  <p>Below script in Codeigniter controller</p>
  
  <pre><code>if (isset($_GET['term'])) {
      $name = strtolower($_GET['term']);
      $this-&gt;model_name-&gt;get_user_names($name);
  }
  </code></pre>
  
  <p>Below script in Codeigniter Model</p>
  
  <pre><code>public function get_user_names($name) {
  
      $this-&gt;db-&gt;select('*');
      $this-&gt;db-&gt;from('users');
  
      $this-&gt;db-&gt;like('username', $name);
  
      $query = $this-&gt;db-&gt;get();
      if ($query-&gt;num_rows() &gt; 0) {
          foreach ($query-&gt;result_array() as $row) {
              $test[] = $row['username'];
  
          }
          echo json_encode($test); //format the array into json data
      }
  }
  </code></pre>