title: Searching/filtering an array
body: <p>I have a question. On my site (Concrete 5 based) I have a block to display a list of icons. I have this array. (The array has many more icons than what I've shown, this is just for an example.)</p>
  
  <pre><code>    &lt;?php  $options = array(
      'icon-adjust' =&gt; 'Icon Adjust',
      'icon-adjustments' =&gt; 'Icon Adjustments',
      'icon-adn' =&gt; 'Icon Adn',
      'icon-alarmclock' =&gt; 'Icon Alarmclock',
      'icon-align-center' =&gt; 'Icon Align-center',
      'icon-align-justify' =&gt; 'Icon Align-justify',
      'icon-align-left' =&gt; 'Icon Align-left',
      'icon-align-right' =&gt; 'Icon Align-right',
      'icon-ambulance' =&gt; 'Icon Ambulance',
      'icon-anchor' =&gt; 'Icon Anchor',
      'icon-anchor2' =&gt; 'Icon Anchor2',
  );
  ?&gt;
  </code></pre>
  
  <p>I want to modify my search box so a user can type in something to filter out results from in the array. (Example: if they search for anchor, they'd see the two icon-anchor fields).</p>
  
  <p>Can anyone help me out with how to go about this?</p>
  
  <p>Here is my code for future reference:</p>
  
  <pre><code>    &lt;script&gt;
  $('input[name=fromPages]').select2({
      placeholder: "&lt;?=t('Search for a Page')?&gt;",
      minimumInputLength: 1,
      width: '100%',
      multiple: true,
      ajax: {
          url: "&lt;?=$view-&gt;action('load_pages')?&gt;",
          dataType: 'json',
          quietMillis: 250,
          data: function (term, page) {
              return {
                  q: term
              };
          },
          results: function (data, page) { // parse the results into the format expected by Select2.
              var results = [];
              $.each(data, function(i, concretePage) {
                  results.push({'id': concretePage.id, 'text': concretePage.name});
              });
              return {
                  results: results
              };
          },
          cache: true
      }
  });
  &lt;/script&gt;
  </code></pre>
  
  <p>And for the select box:</p>
  
  <pre><code>&lt;div class="form-group"&gt;
      &lt;?php echo $form-&gt;label('fromPages', 'Search for an Icon')?&gt;
      &lt;div&gt;
          &lt;?php echo $form-&gt;hidden('fromPages'); ?&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>and a picture: (the top search box would filter results from the opened list)
  <a href="http://i.imgur.com/Ksrb7iQ.png?1" rel="nofollow">http://i.imgur.com/Ksrb7iQ.png?1</a></p>