I am trying to obtain the first entry if nothing is set in the $_POST or $_SESSION but when I output the below using die(print_r($nmcu)); I always only get 1, if I add numbers to the end of "entry 1" and "exit 2" it seems to work but I'm not sure why, I dont want numbers in the names...
<?php
session_start();
$entry = array(
"entry" => array("user" => "username",
"pass" => "password",
"host" => "localhost",
"port" => 1111,
"protocol" => "http"),
"exit" => array("user" => "username",
"pass" => "password",
"host" => "localhost",
"port" => 1111,
"protocol" => "http"));
if (isset($_POST['currentEntry'])) {
$_SESSION['currentEntry'] = $_POST['currentEntry'];
}
if (isset($_SESSION['currentEntry'])) {
$currentEntry = $_SESSION['currentEntry'];
} else {
$keys = array_keys($entry);
$currentEntry = $keys[0];
$_SESSION['currentEntry'] = $currentEntry;
}
$nmcu = $entry[$currentEntry];
?>