Minase Posted September 27, 2009 Share Posted September 27, 2009 hello till now i didn't need multy array but now i need it and im stuck :| $elements = array ( "a" => array ( "base1" => 5, "base2" => 24), "b" => array ( "base1" => 4, "base2" => 55) ); what i need is something like this i need to have 2 values for array a,and 2 values for array b kinda failed if you can explain me how to do this and how to use the double array i will be forever grateful thank you Quote Link to comment https://forums.phpfreaks.com/topic/175694-solved-multy-array/ Share on other sites More sharing options...
Daniel0 Posted September 27, 2009 Share Posted September 27, 2009 So what is your problem? Quote Link to comment https://forums.phpfreaks.com/topic/175694-solved-multy-array/#findComment-925830 Share on other sites More sharing options...
Minase Posted September 27, 2009 Author Share Posted September 27, 2009 i didnt know how to call the second array :| i now though if i use double foreach it will do the job and it did is that correct or im doing it wrong? foreach ($elemets as $a => $b) { foreach ($b as $c => $d) } } is that correct ? thank you Quote Link to comment https://forums.phpfreaks.com/topic/175694-solved-multy-array/#findComment-925836 Share on other sites More sharing options...
Daniel0 Posted September 27, 2009 Share Posted September 27, 2009 How you would traverse it depends on what you want to do with it. Quote Link to comment https://forums.phpfreaks.com/topic/175694-solved-multy-array/#findComment-925838 Share on other sites More sharing options...
Minase Posted September 27, 2009 Author Share Posted September 27, 2009 yes i know thanks for answer now another problem occurred $max = max ($elements); this would be in a single array,but in a double array how would i do it? i want to count all subarrays for each "primary" array thank you Quote Link to comment https://forums.phpfreaks.com/topic/175694-solved-multy-array/#findComment-925840 Share on other sites More sharing options...
Daniel0 Posted September 27, 2009 Share Posted September 27, 2009 You could do like: $max = 0; // just because we need something to start with foreach ($array as $elem) { $max = max($max, max($elem)); } Quote Link to comment https://forums.phpfreaks.com/topic/175694-solved-multy-array/#findComment-925842 Share on other sites More sharing options...
Minase Posted September 27, 2009 Author Share Posted September 27, 2009 thank you very much Quote Link to comment https://forums.phpfreaks.com/topic/175694-solved-multy-array/#findComment-925843 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.