-1

How to post this array into another page.

Array
(
    [0] => Array
        (
            [0] => Client Name
            [1] => Task ID
            [2] => Sub-Task Id
            [3] => Task Specification
            [4] => Billable Minutes
            [5] => Total Spent Time
            [6] => Handled By
        )

    [1] => Array
        (
            [0] => Client1
            [1] => TAS1
            [2] => -
            [3] => 90
            [4] => 01:20:51
            [5] => Vinodkumar M
        )

    [2] => Array
        (
            [0] => Client2
            [1] => TAS2
            [2] => -
            [3] => 60
            [4] => 02:04:42
            [5] => Vinodkumar M
        )

)
6
  • I tried $_SESSION['excelData'] = array($exportToExcel); Dec 22, 2012 at 7:33
  • Use session variable to save Array values in string form using implode function and then use it in another page.
    – RAM
    Dec 22, 2012 at 7:33
  • And what was the problem with what you tried? Please provide some more information... "post this array into another page" is quite vague. Dec 22, 2012 at 7:33
  • Did you put session_start() in both pages? (In the page where you're storing it in session and the one in which you're trying to retrieve it?)
    – asprin
    Dec 22, 2012 at 7:38
  • echo these values in to HIDDEN TEXT and just POST it ! Dec 22, 2012 at 8:05

1 Answer 1

2

You could put it in the session:

session_start();
$_SESSION['array_name'] = $array_name;

Or if you want to send it via a form you can serialize it:

<input type='hidden' name='input_name' value="<?php echo htmlentities(serialize($array_name)); ?>" />

$passed_array = unserialize($_POST['input_name']);

Note that to work with serialized arrays, you need to use POST as the form's transmission method, as GET has a size limit somewhere around 1024 characters.

I'd use sessions wherever possible.

2
  • 1
    I'd agree with laxonline. Store it all into a single $_SESSION variable and then can you carry it across as many pages as you wanted. Just make sure each page opens with the session_start(); to hold the variable on the page.
    – MrTechie
    Dec 22, 2012 at 7:42
  • thanks, using session variable I got the result. Dec 22, 2012 at 9:57

Not the answer you're looking for? Browse other questions tagged or ask your own question.