I have class with a few methods... I call one method and use foreach to loop through the data. During the loop I set a variable to call a method from the same class to get quantities. However, I can't unset that variable and as it loops it adds to the initial value of the variable from the first iteration.
$cart = new search();
//get qty loc array
$qq = array();
$qc = 1;
$whs = $cart->warehouseData($conn, $schema);
foreach($whs as $aW=>$bW){
$qTotals = $cart->checkAvlQtyOneLoc($conn, $item, $aW, $schema);
$qq[$qc]['location'] = $aW;
$qq[$qc]['qty'] = $qTotals;
$qc++;
$qTotals = null;
unset($qTotals);
$qTotals = '';
}
echo '<pre>'.print_r($qq,1).'</pre>';
edit:
just to add to this the return I should get on my $qq[$qc]['qty'] should be: 8,1,1,1,1,..... but instead it returns 8,9,10,11,12,...... etc.
I'm not sure really sure how to unset that $qTotals or if I am doing something completely wrong here. I did read something that mentions setting it to NULL and using unset() but that didn't help.
I appreciate any insight. Thanks..