PHP Session Array Value keeps showing as "Array"

php

Solution

You don't need any sort of override. The script is printing "Array" rather than a value, because you're trying to print to the screen a whole array, rather than a value within an array for example:

$some_array = array('0','1','2','3');

echo $some_array; //this will print out "Array"

echo $some_array[0]; //this will print "0"

print_r($some_array); //this will list all values within the array. Try it out!

`print_r()` is not useful for production code, because its ugly; however, for testing purposes it can keep you from pulling your hair out over nested arrays.

It's perfectly fine to access elements in your array by index: `$some_array[2]`

if you want it in a table you might do something like this:

<table>
    <tr>
    for($i = 0 ; $i < count($some_array) ; $i++) {
        echo '<td>'.$some_array[$i].'</td>';
    }
    </tr>
</table>

Problem

When sending data from a form to a second page, the value of the session is always with the name "Array" insteed of the expected number. The data should get displayed in a table, but insteed of example 1, 2, 3 , 4 i get : Array, Array, Array. (A 2-Dimensional Table is used) Is the following code below a proper way to "call" upon the stored values on the 2nd page from the array ? ``` $test1 = $_SESSION["table"][0]; $test2 = $_SESSION["table"][1]; $test3 = $_SESSION["table"][2]; $test4 = $_SESSION["table"][3]; $test5 = $_SESSION["table"][4]; ``` What exactly is this, and how can i fix this? Is it some sort of override that needs to happen? Best Regards.

Original source