I have the following array:
Array
(
[instructions] => Special Instructions:
[order] => Array
(
[0] =>
[1] => 2
[2] =>
[3] => 1
[4] =>
[5] => 3
[6] =>
[7] =>
[8] =>
[9] =>
[10] =>
[11] =>
)
[item] => Array
(
[0] => KC PORK
[1] => CANADIAN BACON, Whole A-7#
[2] => BREAST MEAT, BNLS SKNLS FRESH 4X10#
[3] => BREAST MEAT, BNLS SKNLS FROZEN 4X10#
[4] => BREASTS, BNLS SKIN ON 24/5oz
[5] => COD, BREADED 2-3oz.
[6] => 3/8
[7] => HASHBROWNS, COARSE SHRED 6X3#
[8] => NN Sliced Bacon (BULK)
[9] => Whole Nitrate Free BNLS Ham 6# ave
[10] => 4/1 NN Beef Franks (Bulk)
[11] => Nat Whole Turkey Br. Roast
)
[code] => Array
(
[0] => 102134
[1] => 102180
[2] => 103625
[3] => 103630
[4] => 103690
[5] => 104154
[6] => 105032
[7] => 105042
[8] => 659007
[9] => 659160
[10] => 659552
[11] => 659570
)
[price] => Array
(
[0] => 6
[1] => 8
[2] => 0.003
[3] => 0.00
[4] => 4.4343
[5] => 5.68
[6] => .55
[7] => 5.8
[8] => 4.96
[9] => 22
[10] => 3.94
[11] => 5.29
)
)
I'm trying to remove the items where the order is null, and resort the keys accordingling. So far I've only been able to get this far:
using:
$i=0;
while ($i < 12) {
if ($_POST[order][$i]==NULL){
unset($_POST[order][$i]);
unset($_POST[item][$i]);
unset($_POST[code][$i]);
unset($_POST[price][$i]);
}
$i++;}
I get this output:
Array
(
[instructions] => Special Instructions:
[order] => Array
(
[1] => 2
[3] => 1
[5] => 3
)
[item] => Array
(
[1] => CANADIAN BACON, Whole A-7#
[3] => BREAST MEAT, BNLS SKNLS FROZEN 4X10#
[5] => COD, BREADED 2-3oz.
)
[code] => Array
(
[1] => 102180
[3] => 103630
[5] => 104154
)
[price] => Array
(
[1] => 8
[3] => 0.00
[5] => 5.68
)
)
My problem is that I cannot figure out for the life of me how to resort or rename the keys so they are in numerical order. ie. 0-1-2-3-4-5 etc. Any help would be greatly appriciated 🙂)