Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Accessing elements in a session array 1

Status
Not open for further replies.

jimoblak

Instructor
Joined
Oct 23, 2001
Messages
3,620
Location
US
I am having trouble pulling values out of a session array. I know that the values are recorded in the session data because I can see it stored on the server:

requesteditems|a:2:{i:0;s:4:"8054";i:1;s:3:"900";}

I want to go through the list of $_SESSION[requesteditems] and create a list:

for ($i = 0; $i <= 30; $i++) {
if (isset($_SESSION[requesteditems][$i])) {
print (&quot;$_SESSION[requesteditems][$i]<br>\n&quot;);
}
}

The output is not what I expect:
8054
900


Instead, I get:
Code:
Array[0]
Array[1]


What am I missing?
 
What does:

print $_SESSION['requesteditems'][$i] . '<br>';

Show? I've found that sometimes PHP gets confused when dealing with associative arrays inside quotes.



What does print_r($_SESSION) show you?


BTW, print does not require the parentheses.

Want the best answers? Ask the best questions: TANSTAAFL!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top