You initially lack knowledge of how arrays are organized in PHP, and what the $ _SESSION variable in it is. As you have already noticed right here, you can simply, without any cycles, write $_SESSION['items'] = $items; , and after receiving the saved goods from the basket (or what you have there for the list of goods stored), going through $_SESSION['items'] as an array. The code will be something like this:
foreach ($_SESSION['items'] as $item) { echo $item['ID']; echo $item['NAME']; /* ... */ }
if you suddenly want to address directly, it can be done like this:
$_SESSION['items'][0]['ID']; $_SESSION['items'][0]['NAME']; /* ... */ $_SESSION['items'][1]['ID']; $_SESSION['items'][1]['NAME']; /* ... */
or so:
$arr = $_SESSION['items']; $arr[0]['ID']; $arr[0]['NAME']; /* ... */ $arr[1]['ID']; $arr[1]['NAME']; /* ... */
Link for compulsory study: http://php.net/manual/ru/language.types.array.php But generally I would advise you to look at / read some kind of training materials in the style of php for dummies, you will certainly find out a couple of unexpected things.
And yes, arrays in PHP are somewhat different from arrays in many other programming languages, if you don’t want to step on a rake every time that is described here - it’s better to spend a day of time on the tip in the paragraph above.
$_SESSION['items'][] = $val;chtoli - SLy_huh$_SESSION['items'] = $items? - SLy_huh