Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Passing 2D arrays between PHP pages (best practice?)

Options
  • 24-02-2010 12:56pm
    #1
    Registered Users Posts: 462 ✭✭


    Can anyone tell me if its possible to pass two dimensional arrays between pages in PHP and what the best practice for it is.

    Could I use the users session for this or is there a better practice?

    The scenario I'm working with is this;

    Given a list of people I'm put them their details into different arrays given certain conditions. These arrays are then used to print a report to a web page. The user can then select any of these groups or arrays to make a printable PDF. So what I'm doing at the minute is running code on one page to split up the people into the groups and then the same again on a different page to make the PDF. Instead of doing all this processing twice I'd like to just pass the appropriate array to the PDF page.

    Anyone?


Comments

  • Registered Users Posts: 3,140 ✭✭✭ocallagh


    As long as the data in the array is small enough you could use sessions.

    Ideally if you are querying and presenting data you should use a database. In your example you'd build an sql query (based on user input) to extract the data. You could place the code which builds the query in a common include file so multiple php pages could access the same data and present it differently.


Advertisement