ts2000abc Posted March 30, 2009 Share Posted March 30, 2009 I should make array such as this; by combining two arrays: $days = array( 2=>array(NULL,'NULL',''), 3=>array(NULL,'NULL',''), 8=>array(NULL,'NULL',''), 22=>array(NULL,'NULL',''), 26=>array(NULL,'NULL',''), ); those values 2,3,8...etc should be taken from another array. So is it possible somehow to use foreach (or other) loop for creating this multidimensional array. (the '=>' marking is giving trouble when im trying create this array through foreach loop) Quote Link to comment https://forums.phpfreaks.com/topic/151805-multidimensional-array-problem/ Share on other sites More sharing options...
Maq Posted March 30, 2009 Share Posted March 30, 2009 Sorry not sure what you mean or where the other array comes from. Could you post the print out of both arrays you need to combine, and what you want the resulting array to look like using "print_r($array);" perhaps? Quote Link to comment https://forums.phpfreaks.com/topic/151805-multidimensional-array-problem/#findComment-797072 Share on other sites More sharing options...
PHP Monkeh Posted March 30, 2009 Share Posted March 30, 2009 Is this what you want to do? <?php $firstArray = array("1", "2", "8"); $secondArray = array(); for($i=0; $i<count($firstArray); $i++) { $secondArray[$firstArray[$i]] = array(NULL, 'NULL', ''); } print_r($secondArray); ?> Quote Link to comment https://forums.phpfreaks.com/topic/151805-multidimensional-array-problem/#findComment-797086 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.