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]; } Link to comment https://forums.phpfreaks.com/topic/123396-solved-array-with-variable/ Share on other sites More sharing options...
Mchl Posted September 9, 2008 Share Posted September 9, 2008 What's your question? Link to comment https://forums.phpfreaks.com/topic/123396-solved-array-with-variable/#findComment-637323 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 Link to comment https://forums.phpfreaks.com/topic/123396-solved-array-with-variable/#findComment-637329 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]; } Link to comment https://forums.phpfreaks.com/topic/123396-solved-array-with-variable/#findComment-637331 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! Link to comment https://forums.phpfreaks.com/topic/123396-solved-array-with-variable/#findComment-637333 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.