I have a page that acts like a controller, more or less (I'm not using frameworks) named control.php This page has a array declared on top and if's that verifies the page that called.Like this:
<?php
$arr= array();
$reference=str_replace("/","",parse_url($_SERVER['HTTP_REFERER'],PHP_URL_PATH));
if($reference=="page1.php"){
$value="pages";
array_push($arr, $value);
header("Location: page2.php");
}else($reference=="page2.php"){ print_r($arr); }
The objective is that when page1 call control.php it adds to the array and when page2 call control.php it prints the array. The problem that i don't understand is that if i print the array right after adding it added, but when i do it when is the page2, the array is empty.Declaring the array on top of the page doesn't make it available to all control.php?