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!
<?php
// create an array called 'fruit' (with 4 elements)
$fruit = array (0=>'banana',
1=>'arancia',
2=>'limone',
3=>'pesca');
// start a session , IRL this will give an error because
// session_start() needs to be called before anything
// else
session_start();
// if the session variable $_SESSION['count'] is not set,
// the $count variable is assigned a value of 0
if (!isset($_SESSION['count'])) {
$count = 0;
// if the session variable is set, increment it by 1.
// no idea on the % symbol.
} else {
$count=$_SESSION['count']++ % 4;
}
// assign the value of the $count variable to the session
// variable $_SESSION['count']
$_SESSION['count'] = $count;
// display the element from the array that has the index
// value of $count
echo $fruit[$count];
?>
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering