[ ]


[ ]

0
NAN
[ ]
[ ]
	
session_start();

if(isset($_POST['price'])){
	$_SESSION['price'] = $_POST['price'];
}

$price = $_POST['price'];

// Coz if value already exist then we keep
if (!isset($_SESSION['mixe'])) {
		$_SESSION['mixe'] = [];
}
// INIT Sample Array
if(isset($_POST['init'])){
		$_SESSION['mixe'] = [1,2,3,4,5,6,7,8,9];
}

// EREASE SESSIONS ALL
if(isset($_POST['supp'])){
	session_destroy();
	header("Location: array_functions.php?#anchor");
}
// ARRAY_SHIFT EREASE FIRST
if(isset($_POST["shift"])){
		array_shift($_SESSION['mixe']);
		header("Location: array_functions.php?#anchor");
}
// ARRAY_POP EREASE LAST
if(isset($_POST["pop"])){
		array_pop($_SESSION['mixe']);
		header("Location: array_functions.php?#anchor");
}


// ARRAY_UNSHIFT ADD DEBUT
if(isset($_POST["unshift"])){
	if(empty($_POST['price'])){
			$msg ='Les champs sont vides';
	}else{
		array_unshift($_SESSION['mixe'], $price);
		header("Location: array_functions.php?#anchor");
	}
}
// ARRAY_PUSH ADD FIN
if(isset($_POST["push"])){
	if(empty($_POST['price'])){
			$msg ='Les champs sont vides';
	}else{
		array_push($_SESSION['mixe'], $price);
		header("Location: array_functions.php?#anchor");
	}
}
// PARTIE BONUS
if (isset($_SESSION['mixe'])) {
	$notes = $_SESSION['mixe'];
	$addition = array_sum($notes);
	$moyenne = round($addition / count($notes),1);
	$reverse = array_reverse($notes);
	$sort = $reverse;
	sort($sort);
}

// Display here
foreach($_SESSION['mixe'] as $mix){
	$result .= " $mix ";
}
	
1080