stijn0713 Posted May 21, 2012 Share Posted May 21, 2012 i have 2 arrays, say: $c = array (7500, 8200, 4000) and $variables = (x1, x2, x3 etc....) now, i want to map these arrays so that the coëfficients are the keys, and the variables values in a mapper array. I tried this: $mapper = array(); foreach ($c as $value){ $b = 1; $mapper($value => $variabelen[$b]); $b++; } but apparently that doesnt work. Any help would be appreciated! Quote Link to comment https://forums.phpfreaks.com/topic/262885-filling-array-with-both-keys-and-values-in-loop/ Share on other sites More sharing options...
batwimp Posted May 21, 2012 Share Posted May 21, 2012 It sounds like you want to use something like array_combine() http://us2.php.net/manual/en/function.array-combine.php Quote Link to comment https://forums.phpfreaks.com/topic/262885-filling-array-with-both-keys-and-values-in-loop/#findComment-1347404 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.