Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

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

  • 24-02-2010 12:56PM
    #1
    Registered Users, Registered Users 2 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, Registered Users 2 Posts: 3,141 ✭✭✭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