fezzik Posted November 11, 2006 Share Posted November 11, 2006 Is it possble to use a for loop to create a series of variables and assign values to them? The below loop is incorrect. I'm attempting to assign $_SESSION['preloaded_name_X] = $preloaded_numX. X is equal to 1 thru 10.for ( $preloadCnt = 1; $preloadCnt <= 10; $preloadCnt ++ ) { $_SESSION['preloaded_name_'.$preloadCnt] = $preloaded_name.$preloadCnt; $_SESSION['preloaded_num_'.$preloadCnt] = $preloaded_num.$preloadCnt;}Any help is appreciated.Fezzik Quote Link to comment Share on other sites More sharing options...
fezzik Posted November 11, 2006 Author Share Posted November 11, 2006 This works:for ( $preloadCnt = 1; $preloadCnt <= 10; $preloadCnt ++ ) { $_SESSION['preloaded_name_'.$preloadCnt] = $_POST['preloaded_name'.$preloadCnt]; $_SESSION['preloaded_num_'.$preloadCnt] = $_POST['preloaded_num'.$preloadCnt];} 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.