cooldude832 Posted December 8, 2007 Share Posted December 8, 2007 I have an array in my session variable that is like $_SESSION['recent_items'][0]['ItemNumber'] = 1; $_SESSION['recent_items'][1]['ItemNumber'] = 2; $_SESSION['recent_items'][2]['ItemNumber'] = 3; and I want to make sure somethign isn't already in the array with that name so if I say <?Php $Item_num = 2; if(in_array($item_num,$_SESSION['recent_items'])){ echo "yes"; } ?> should it echo yes??? Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted December 8, 2007 Share Posted December 8, 2007 It works, if your array is structured correctly (tested) - <?php session_start(); $_SESSION['recent_items']['ItemNumber'][0] = 1; $_SESSION['recent_items']['ItemNumber'][1] = 2; $_SESSION['recent_items']['ItemNumber'][2] = 3; $item_num = 2; if(in_array($item_num,$_SESSION['recent_items']['ItemNumber'])){ echo "yes"; } Quote Link to comment 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.