Explode Unknown amount of variables
<p>I have a string of data which is an unknown length eg <code>$myvar = "data,data";</code> and i want to <code>explode</code> the string eg <code>list($a, $b) = explode(",", $myvar)</code> which works great if I know the length of the data, but im not sure how to handle variable lengths.</p>

<p>i was thinking of using <code>if</code> statments. </p>

<p>eg: <code>$letter_count = substr_count($myvar, ',');</code> </p>

<pre><code>if($letter_count == 2) { list($a, $b) = explode(",", $myvar) }
elseif($letter_count == 3) { list($a, $b, $c) = explode(",", $myvar) } 
</code></pre>

<p>but this is not practical, anyone got any ideas how else i could do this?</p>
