Hi all
I am looking to use an associative array to store the following:
key = Section Name
value = Script name
For example, here is my array:
$sections = array(
'Section 1' => 'section1',
'Section 2' => 'section2',
'Section 3' => 'section3',
'Section 4' => 'section4',
'Section 5' => 'section5',
'Section 6' => 'section6',
'Section 7' => 'section7',
'Section 8' => 'section8',
'Section 9' => 'section9'
);
Now, what I want to do is to be able to:
a) if the current session variable is not set, set it to be the first element of the array
b) if I press either of my next or previous buttons, get the next() or previous() key/value from the array based on my current() position (which I store in a session array as above)
The problem I have is I am failing at point 'A' above!
I have the following code:
if (!isset($_SESSION['S_CURRENT_SECTION'])) {
$_SESSION['S_CURRENT_SECTION'] = current($sections);
}
echo "Current: " . $_SESSION['S_CURRENT_SECTION'];
But this does not echo anything - any reason why?
p.s. I have session_start() at the top of my page.
Thanks for reading