I have a foreach loop that I am repeating. I try to have the variable βexplodeβ into parts and then be added to the corresponding arrays using list (), for example:
list($a[], $b[], $c[]) = explode(':', $loop);
Can list () not do this? These are errors with
Fatal error: operator [] is not supported for strings
I suppose I could just use the temporary variables in the list () and then add them to the corresponding arrays later, for example:
foreach($array as $loop) { list($a1, $b2, $c3) = explode(':', $loop); $a[] = $a1; $b[] = $b2; $c[] = $c3; }
Is this a better or more efficient way to do this (e.g. fully using list ())?
source share