I have the following code to build an order string in a specific format:
$title=$SESSION['title'];
$purchase=$SESSION['purchase'];
$price=$_SESSION['price'];
$numcount=count($purchase);
$orderstring='';
echo count($title)."<br>";
echo count($purchase)."<br>";
echo count($price)."<br>";
for ($i=0; $i<=$numcount; $i++){
$orderstring.= $purchase[$i]. "~" . $title[$i] . "~" . $price[$i] . "~1~N~||";
}
echo $orderstring;
My output does not match the number of items in the arrays. This is the output from the browser window:
4
4
4
1~Test package #1~25.00~1~N~||2~Package # 2 -2 Plays~50.00~1~N~||5~Test Mult Edit~50.00~1~N~||3~Package #3~100.00~1~N~||~~~1~N~||
Notice the last entry between the double pipes.
That make 5 items instead of 4. Where am I going wrong?
How do I keep the last entry from appending?