title: Php array explode a char
body: <p>This is my array:</p>
  
  <pre><code>array:4 [
    0 =&gt; "Family Deluxe for 4 Person x 1"
    1 =&gt; "Studio Deluxe for 2 Person x 1"
    2 =&gt; "Additional Adult x 2"
    3 =&gt; "Additional Children x 2"
  ]
  </code></pre>
  
  <p>When I pass into a <code>foreach</code> loop to remove the <code>x</code> and get the count, I encounter the following output result:</p>
  
  <pre><code>array:4 [
    0 =&gt; array:1 [
      "Family Delu" =&gt; "e for 4 Person "
    ]
    1 =&gt; array:1 [
      "Studio Delu" =&gt; "e for 2 Person "
    ]
    2 =&gt; array:1 [
      " Additional Adult " =&gt; " 2"
    ]
    3 =&gt; array:1 [
      " Additional Children" =&gt; " 2"
    ]
  ]
  </code></pre>
  
  <p>The issues is, there is <code>x</code> char in the string <code>Deluxe</code> so the loop getting confuse on where to start an <code>explode()</code>. Following were my code for <code>foreach</code>:</p>
  
  <pre><code>foreach($a as $s) {
              list($size, $quantity) = explode('x', $s);
              $data[] = array($size =&gt; $quantity);
              $sumVariant += $quantity;
          }
  </code></pre>
  
  <p>How can I get <code>explode()</code> to recognize the <code>x</code> with spaces on both side? Thanks!!</p>