flit Posted April 8, 2008 Share Posted April 8, 2008 Hi there, Can anyone help me make an array out of session values? The session file looks like this: sessionvar|s:7:"3,2,1"; Example: $id = $_SESSION['sessionvar']; echo $id ==->3,2,1 While ...... $query = "SELECT * FROM books where id=$id[0]" ..... ..... Loop In the first loop the first array must be used[0] In the second loop the second array must be used[1] In the third loop the third array must be used[2] -->??? $id = array[$id]; Link to comment https://forums.phpfreaks.com/topic/100229-how-to-make-an-array-out-of-session-valuesintegers/ Share on other sites More sharing options...
Barand Posted April 8, 2008 Share Posted April 8, 2008 <?php $id = $_SESSION['sessionvar']; // '3,2,1' $idArray = explode(',', $id); foreach ($idArray as $id) { $query = "SELECT * FROM books where id=$id" // process } ?> Link to comment https://forums.phpfreaks.com/topic/100229-how-to-make-an-array-out-of-session-valuesintegers/#findComment-512497 Share on other sites More sharing options...
flit Posted April 8, 2008 Author Share Posted April 8, 2008 Thanks dude, I'm gonna try that Link to comment https://forums.phpfreaks.com/topic/100229-how-to-make-an-array-out-of-session-valuesintegers/#findComment-512516 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.