0

Think of it as a poor mans template system. I want to store my values into a data array and then continue processing the view on another page. What PHP command would I use to accommodate this?

5
  • Store the values in the session and redirect to the next page. Or include the next page and exit the current page. Commented Aug 26, 2010 at 17:48
  • 1
    Could u plz explain better what you are trying to accomplish?! You can store a PHP array in a PHP arrfile.php and simply include('arrfile.php') from all your pages. Commented Aug 26, 2010 at 17:49
  • @Marco Demaio: this is really a bad idea. What happens if there are multiple requests coming, and they include/overwrite arrfile.php? Commented Aug 26, 2010 at 17:51
  • @Yorirou: overwrite what, a request can't overwrite the arrfile.php. The file contains the array with all the data he needs, he wrote those data down by his hands, so his pages are including the arrfile.php (or call it config.php) and they can all see the data. Unless I did not understood what he wants to do, that's why I asked to explain better. Commented Aug 26, 2010 at 18:13
  • Do you mean you want to fill out a form and then have that data passed to another page? Commented Aug 26, 2010 at 19:30

2 Answers 2

1

You can include the second file and the second file will have access to all data.

Sign up to request clarification or add additional context in comments.

Comments

0

All you need to do is set your array, and then include the page that will display it. Your included page will have access to the value(s) of $myArray.

Main Page

<?php
    $myArray= Array(1, 2, 3);
    include('ArrayDisplayPage.php');
?>

ArrayDisplayPage.php

<?php
    var_dump($myArray);
?>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.