Accessing multidimensional arrays from $_SESSION array

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
pointone
Forum Newbie
Posts: 2
Joined: Mon Jun 03, 2002 8:54 pm
Contact:

Accessing multidimensional arrays from $_SESSION array

Post by pointone »

If I create a variable like $var[0][0] and assign the string "Hello" to it, then session_register('var'). On the subsequent pages I want to use this variable how do I access it with the $_SESSION[ ???? ] array??
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

try this

Code: Select all

<?php
session_start();

if ( !isset($_SESSION&#1111;'var']) )
&#123;
	$var&#1111;0]&#1111;0] = 'test00';
	$var&#1111;1]&#1111;1] = 'test11';
	$_SESSION&#1111;'var'] = $var;
	print('<html><body>values set, refresh now</body></html>');
&#125;
else
&#123;
	print($_SESSION&#1111;'var']&#1111;1]&#1111;1]);
	unset($_SESSION&#1111;'var']);
&#125; ?>
pointone
Forum Newbie
Posts: 2
Joined: Mon Jun 03, 2002 8:54 pm
Contact:

Thank you, Thank you, Thank you!!!

Post by pointone »

All I needed was $_SESSION['blah'][0].
I was doing $_SESSION['blah[0]'] :D
Post Reply