unxposed Posted September 9, 2008 Share Posted September 9, 2008 Okay this is almost certainly a stupid question as I'm probably going about it the wrong way, but it mightgive you an idea of what I'm trying to achieve, any ideas? thanks! $test = array( array(15, 1), array(18, 1), array(97, 2), array(100, 2), array(103, 3), ); if ($test[$a][0] == 15) { echo $test[$a][1]; } Quote Link to comment Share on other sites More sharing options...
Mchl Posted September 9, 2008 Share Posted September 9, 2008 What's your question? Quote Link to comment Share on other sites More sharing options...
unxposed Posted September 9, 2008 Author Share Posted September 9, 2008 Well this doesn't work... how do I find the position of a secondary array in the first array when I know what both values of the secondary array are - the first of which will always be unique. Thanks Quote Link to comment Share on other sites More sharing options...
Mchl Posted September 9, 2008 Share Posted September 9, 2008 You mean like this? $test = array( array(15, 1), array(18, 1), array(97, 2), array(100, 2), array(103, 3), ); foreach ($test as $key => $nestedArray) { if ($nestedArray[0] == 15) echo $nestedArray[1]; } Quote Link to comment Share on other sites More sharing options...
unxposed Posted September 9, 2008 Author Share Posted September 9, 2008 Thanks, works a treat. Exactly what I was after! 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.