title: PHP: Exploding array elements
body: <p>I have a 2D array which I have exploded from a string. Once it has exploded this is what is output:</p>
  
  <pre><code>---&gt; 0 - 16~4~0.0~~~~false~~~~ 
  ---&gt; 1 - 1000.0~21.75~L~1~2.0~2.0~L~2~ 
  ---&gt; 2 - 
  ---&gt; 0 - 2~5~951.3~6.4~~~false~~~~ 
  ---&gt; 1 - 1000.0~11.77~L~1~ 
  ---&gt; 2 - 
  ---&gt; 0 - 3~6~1269.02~5.1~~~false~~~~ 
  ---&gt; 1 - 5.0~213.66~L~1~4.9~2.56~L~2~4.6~19.5~L~3~ 
  ---&gt; 2 - 5.1~53.44~B~1~5.4~8.48~B~2~5.5~15.53~B~3~ 
  </code></pre>
  
  <p>I want to make it so that for each position in the array it only takes the first value before the ~. I am unsure how to do this. This is the code I have so far:</p>
  
  <pre><code>$test = explode(":", $string);
  foreach($test as &amp;$value) $value = explode('|', $value);
  </code></pre>
  
  <p>Just in case you need it this is the original string input:</p>
  
  <blockquote>
    <p>1~1~828.32~12.5~~~false~~~~|1000.0~41.73~L~1~2.0~2.0~L~2~|:4~2~4.16~12.5~~~false~~~~|1000.0~21.75~L~1~2.0~2.0~L~2~|:9~3~0.16~24.0~~~false~~~~|1000.0~21.75~L~1~2.0~2.0~L~2~|:16~4~0.0~~~~false~~~~|1000.0~21.75~L~1~2.0~2.0~L~2~|:2~5~951.3~6.4~~~false~~~~|1000.0~11.77~L~1~|:3~6~1269.02~5.1~~~false~~~~|5.0~213.66~L~1~4.9~2.56~L~2~4.6~19.5~L~3~|5.1~53.44~B~1~5.4~8.48~B~2~5.5~15.53~B~3~:8~7~111.92~7.0~~~false~~~~|6.8~6.78~L~1~6.6~148.39~L~2~6.4~3.7~L~3~|7.6~128.0'...</p>
  </blockquote>
  
  <p>I would like the output to be:</p>
  
  <pre><code>---&gt; 0 - 16 
  ---&gt; 1 - 1000.0
  ---&gt; 2 - 
  ---&gt; 0 - 2
  ---&gt; 1 - 1000.0
  ---&gt; 2 - 
  ---&gt; 0 - 3
  ---&gt; 1 - 5.0 
  ---&gt; 2 - 5.1 
  </code></pre>