Menu
Why doesn’t the amount of values in the array get displayed, to reflect what in the array, upon calling the writeShoppingCart() function? – The amount stays at 0, Why is this?
[CODE]<?php
session_start();
function writeShoppingCart()
{
echo count($array);
}
if(isset($_SESSION[‘ids’]) && is_array($_SESSION[‘ids’]))
{
$array = $_SESSION[‘ids’];
}
else
{
$array = array();
}
if (!in_array($_GET[‘id’], $array))
{
$array[] = $_GET[‘id’];
}
else
{
echo “ID Exists”;
}
$_SESSION[‘ids’] = $array;
writeShoppingCart();
print_r($array);
?>