title: Most efficient solution: trim, capitalise and explode by comma for a string
body: <p>I have a string like so:</p>
  
  <pre><code>Quaint village location, seaside views, four bedrooms
  </code></pre>
  
  <p>I need to do the following:</p>
  
  <ul>
  <li>Take each comma separated item and add it into an array</li>
  <li>Remove whitespace from beginning and end</li>
  <li>Capitalise the first letter</li>
  </ul>
  
  <p>So for example, the above string becomes:</p>
  
  <pre><code>array(
     [0] =&gt; 'Quaint village location',
     [1] =&gt; 'Seaside views',
     [2] =&gt; 'Four bedrooms',
  )
  </code></pre>
  
  <p>I have started this code block using <code>trim</code>, <code>explode</code> and <code>ucfirst</code> but I don't think I'm going about it a very efficient way.</p>
  
  <pre><code>iif(get_field('property_information') != NULL){
          $raw_facilities_list = explode(",", get_field('property_information'));
          $other_facilities_list = [];
          foreach($raw_facilities_list as $facility){
              $facility = trim($facility);
              $facility = ucfirst($facility);
              array_push($other_facilities_list,$facility);
          }
          $property['extra_features'] = $other_facilities_list;
          echo '&lt;pre&gt;';
              var_dump($property);
          echo '&lt;/pre&gt;';
      }
  </code></pre>
  
  <p>What is the most efficient way to perform these 3 tasks?</p>