I have few php pages. One is a dynamic form, one is an file holding some arrays, one is a script that is the action for the form and the other two are to update the array. What I am trying to do is append an array using array_push to add files to the array. Howver it only seems to work local to the page you are on. I am using the array as an include at the moment, however I am assuming sessions are the way round it, but I dont really get it.
Ideally what I want to do is update the array so it can be used over many pages at one time.
Here are the forms
<title>Add new Items</title>
<form action="ammendArray.php" method="post">
<p>Add new items</p>
Add up to 3 new cars <br/>
Type 1<input type="text" name="CarOne" /><br/>
Type 2<input type="text" name="CarTwo" /><br/>
Type 3<input type="text" name="CarThree" /><br/>
script to change array
$carone = $_POST['carone'];
for($i=0; $i <=count($carChange); $i++)
$green_key = array_search($shoe, $model); // returns the first key whose value is 'green'
$model[$green_key] = $carone; // replace 'green' with 'apple'
Please help me if you can, and if you want more information please ask
As you seem to already recognize, when you include the module with the arrays, you are getting a fresh copy every time. If your intent is to pass these arrays around and update them, then you are right again, using session variables would be the best way to do it. In your include module, you could enclose all the definitions in an if:
That way you'll only do the definitions once. All of your arrays need to become Session variables as I showed above for mode1. Anywhere that you use the arrays, you will now reference the Session versions. Any modules that use the session variables must have a session_start statement.