Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 04-11-2009, 10:23 AM Sessions As Arrays
evans123's Avatar
Ultra Talker

Posts: 468
Trades: 0
I have a session $_SESSION['match_viewer']['formation_place'][$row['player_id']]['player_left'] and when you do print_r($_SESSION['match_viewer']['formation_place'][$row['player_id']]['player_left']); it prints the array in an unuseable state. Is there any function i can use to allow me to get the session into a useable state?

This is the output of the array:
PHP Code:
Array (     [26] => Array         (             [player_top] => 49.2             [player_left] => 173         )      [32] => Array         (             [player_left] => 58         )      [29] => Array         (             [player_top] => 49.2             [player_left] => 115         )      [20] => Array         (             [player_top] => 147.5             [player_left] => 115         )      [22] => Array         (             [player_top] => 147.5             [player_left] => 230         )      [23] => Array         (             [player_top] => 196.7             [player_left] => 115         )      [24] => Array         (             [player_top] => 73.8             [player_left] => 230         )      [27] => Array         (             [player_top] => 98.3             [player_left] => 115         )      [28] => Array         (             [player_top] => 147.5             [player_left] => 173         )      [31] => Array         (             [player_top] => 98.3             [player_left] => 173         )      [18] => Array         (             [player_top] => 196.7             [player_left] => 173         )  ) 
Thanks for any help.

Last edited by evans123; 04-11-2009 at 10:59 AM..
evans123 is offline
Reply With Quote
View Public Profile Visit evans123's homepage!
 
 
Register now for full access!
Old 04-11-2009, 11:21 AM Re: Sessions As Arrays
Junior Talker

Posts: 1
Trades: 0
I dont know what u mean by useable state but instead of doing a print_r() which is for recursive print (to check all array things) do a simple echo or print like this
print $_SESSION['match_viewer']['formation_place'][$row['player_id']]['player_left'];
echo $_SESSION['match_viewer']['formation_place'][$row['player_id']]['player_left'];
crivion is offline
Reply With Quote
View Public Profile
 
Old 04-11-2009, 11:23 AM Re: Sessions As Arrays
wayfarer07's Avatar
Poo on You

Latest Blog Post:
Introducing WowWindow
Posts: 3,987
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
And what is not usable about it?
__________________
I build web things. I work for the startup
Please login or register to view this content. Registration is FREE
.
wayfarer07 is online now
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Old 04-11-2009, 11:26 AM Re: Sessions As Arrays
evans123's Avatar
Ultra Talker

Posts: 468
Trades: 0
you get this error message on the array because it has no commas in it!

PHP Code:
Parse error:  syntax errorunexpected '['expecting ')' in /home/championshipfl/HNKY2LM4/htdocs/includes/match_viewer_content.php on line 34 
evans123 is offline
Reply With Quote
View Public Profile Visit evans123's homepage!
 
Old 04-11-2009, 11:28 AM Re: Sessions As Arrays
evans123's Avatar
Ultra Talker

Posts: 468
Trades: 0
When u echo or print u get "Array"
evans123 is offline
Reply With Quote
View Public Profile Visit evans123's homepage!
 
Old 04-11-2009, 11:52 AM Re: Sessions As Arrays
wayfarer07's Avatar
Poo on You

Latest Blog Post:
Introducing WowWindow
Posts: 3,987
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
What's on line 34?
__________________
I build web things. I work for the startup
Please login or register to view this content. Registration is FREE
.
wayfarer07 is online now
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Old 04-11-2009, 12:31 PM Re: Sessions As Arrays
evans123's Avatar
Ultra Talker

Posts: 468
Trades: 0
posted first! when u prin using print_r your not able to tell it to still have commas so it forces an error when you try and do a foreach on it.

I want to be able to print the array out and save it in a database so i can obtain it at a later date.

Last edited by evans123; 04-11-2009 at 12:32 PM..
evans123 is offline
Reply With Quote
View Public Profile Visit evans123's homepage!
 
Old 04-11-2009, 02:20 PM Re: Sessions As Arrays
wayfarer07's Avatar
Poo on You

Latest Blog Post:
Introducing WowWindow
Posts: 3,987
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
Separate each array item with a comma, and store it as one big string (no need to use print_r anywhere, that is only a debugging tool). Then, when you extract it, use the explode function to make it back into an array.
__________________
I build web things. I work for the startup
Please login or register to view this content. Registration is FREE
.

Last edited by wayfarer07; 04-11-2009 at 02:22 PM..
wayfarer07 is online now
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Reply     « Reply to Sessions As Arrays
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.46559 seconds with 12 queries