Freedom-n-Democrazy Posted October 9, 2011 Share Posted October 9, 2011 Is there an equivalent to * (any) in a $_SESSION? Something like this: foreach ($_SESSION['cart']['content'][*]['Large'] as $content) { Quote Link to comment https://forums.phpfreaks.com/topic/248724-equivalent-of-in-a-_session/ Share on other sites More sharing options...
Psycho Posted October 9, 2011 Share Posted October 9, 2011 No, you would have to build your own function to do something like that Quote Link to comment https://forums.phpfreaks.com/topic/248724-equivalent-of-in-a-_session/#findComment-1277355 Share on other sites More sharing options...
Freedom-n-Democrazy Posted October 9, 2011 Author Share Posted October 9, 2011 I see. Do you mean something like this?: $all = $_SESSION['cart']['content'][]; foreach ($_SESSION['cart']['content']['$all']['sizel'] as $content) { Quote Link to comment https://forums.phpfreaks.com/topic/248724-equivalent-of-in-a-_session/#findComment-1277364 Share on other sites More sharing options...
MasterACE14 Posted October 9, 2011 Share Posted October 9, 2011 what are you trying to achieve? surely there's a better way of doing whatever it is you're trying to do. Quote Link to comment https://forums.phpfreaks.com/topic/248724-equivalent-of-in-a-_session/#findComment-1277373 Share on other sites More sharing options...
Freedom-n-Democrazy Posted October 9, 2011 Author Share Posted October 9, 2011 There is. I just re-wrote my code: if ($_POST['size'] == "Small") { if (isset($_SESSION['cart']['content'][$_POST[id]])) { $_SESSION['cart']['content'][$_POST[id]]['sizes'] += $_POST['quantity']; } else { $_SESSION['cart']['content'][$_POST[id]] = array ('id' => $_POST['id'], 'sizes' => $_POST['quantity']); } } elseif ($_POST['size'] == "Large") { if (isset($_SESSION['cart']['content'][$_POST[id]])) { $_SESSION['cart']['content'][$_POST[id]]['sizel'] += $_POST['quantity']; } else { $_SESSION['cart']['content'][$_POST[id]] = array ('id' => $_POST['id'], 'sizel' => $_POST['quantity']); } } Quote Link to comment https://forums.phpfreaks.com/topic/248724-equivalent-of-in-a-_session/#findComment-1277375 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.