Monkuar Posted March 7, 2012 Share Posted March 7, 2012 $order = array(0,1,2); echo serialize($order); Shows: a:3:{i:0;i:0;i:1;i:1;i:2;i:2;} which is fine, because I can use unserialized. But I need to let me users switch between 0,1,2 to be in what ever order they want it to!, how would I go about saving the data ? Link to comment https://forums.phpfreaks.com/topic/258434-php-serialize/ Share on other sites More sharing options...
requinix Posted March 7, 2012 Share Posted March 7, 2012 If they're just numbers a simple implode() would work (and be better than serializing the array). What are you asking about? Link to comment https://forums.phpfreaks.com/topic/258434-php-serialize/#findComment-1324732 Share on other sites More sharing options...
marcus Posted March 7, 2012 Share Posted March 7, 2012 Use a session to store the user's selected value. session_start(); $_SESSION['selected'] = 2; Link to comment https://forums.phpfreaks.com/topic/258434-php-serialize/#findComment-1324733 Share on other sites More sharing options...
Monkuar Posted March 7, 2012 Author Share Posted March 7, 2012 If they're just numbers a simple implode() would work (and be better than serializing the array). What are you asking about? $middle=array ( "0" => array ( "section" => $notes, "hide" => $display['1'], "left" => "0", "right" => "0", "middle" => "0" ), "1" => array ("section" => $signature, "hide" => $display['2'], "left" => "0", "right" => "0", "middle" => "0" ), "2" => array ("section" => $friends, "hide" => $display['4'], "left" => "0", "right" => "0", "middle" => "0" ), ); $order = array(0,1,2); echo serialize($order); foreach ($order as $index) { if ($middle[$index]['hide'] != 1){ if ($middle[$index]['left'] == 1){ $lside .= $middle[$index]['section']; } if ($middle[$index]['right'] == 1){ $rside .= $middle[$index]['section']; } if ($middle[$index]['middle'] == 1){ $mside .= $middle[$index]['section']; } } } See the $order = array(0,1,2); Is the ordered list of each users profile, I want them to beable to edit the $order = array (0,1,2) to any order they want (can only be 0 1 or 2 numbers, and numbers cannot be repeated, or it will just show 2 of the sections. I was looking into serialzed and was hoping it would be the best way to do this? i've Tried a simple varchar field with exploded 0,1,2 but there was no validation process I could think of to fit my needs, (0 1 or 2 and numbers cant be repated) i want my users to choose a order of the list in that $order variable, is serialized to much for this simple task? I am still stumped Link to comment https://forums.phpfreaks.com/topic/258434-php-serialize/#findComment-1324734 Share on other sites More sharing options...
scootstah Posted March 7, 2012 Share Posted March 7, 2012 I was looking into serialzed and was hoping it would be the best way to do this? i've Tried a simple varchar field with exploded 0,1,2 but there was no validation process I could think of to fit my needs, (0 1 or 2 and numbers cant be repated) i want my users to choose a order of the list in that $order variable, is serialized to much for this simple task? I am still stumped serialize isn't going to magically validate it for you. In fact, serialize isn't going to validate anything at all. You need to do that before you begin to think about how to store it. Link to comment https://forums.phpfreaks.com/topic/258434-php-serialize/#findComment-1324735 Share on other sites More sharing options...
Monkuar Posted March 7, 2012 Author Share Posted March 7, 2012 i edited to make it more easier $middle=array ( "Notes" => array ( "section" => $notes, "hide" => $display['1'], "left" => "0", "right" => "0", "middle" => "1" ), "Signature" => array ("section" => $signature, "hide" => $display['2'], "left" => "0", "right" => "0", "middle" => "1" ), "Friends" => array ("section" => $friends, "hide" => $display['4'], "left" => "0", "right" => "0", "middle" => "1" ), ); $order = array("Notes","Signature","Friends"); I will put a Arrow next to each section for them to click on, but dunno how I would update the row? lol i mean if they click up arrow on the friends tab, i need to move the friends behind the signature/etc so on, how Can I know what they're going to click and do a action for it? :shrug: Link to comment https://forums.phpfreaks.com/topic/258434-php-serialize/#findComment-1324738 Share on other sites More sharing options...
trq Posted March 7, 2012 Share Posted March 7, 2012 How many times are you going to ask this same question? Link to comment https://forums.phpfreaks.com/topic/258434-php-serialize/#findComment-1324771 Share on other sites More sharing options...
Recommended Posts