I've been reading about loops this morning, to try to improve this snippet of code:
$deliveryoutcode1 = array();
$deliveryoutcode1 = explode(",",$rows['deliveryoutcode1']);
$deliveryoutcode2 = array();
$deliveryoutcode2 = explode(",",$rows['deliveryoutcode2']);
$deliveryoutcode3 = array();
$deliveryoutcode3 = explode(",",$rows['deliveryoutcode3']);
I started to read about loops this morning and I came up with this:
$i=1;
while ($i <= 3) { // Output values from 0 to 3
$deliveryoutcode[$i] = array();
$deliveryoutcode[$i] = explode(",",$rows['deliveryoutcode' . $i . '']);
$i++;
}
This works great, but I'm wondering if there is a better way to do this. It appears as though I've come up with the best way but as this is my first attempt at loops, I better ask the experts.