dhimo Posted June 8, 2007 Share Posted June 8, 2007 Hi everyone. I have these two arrays: <?php$array1[] = 57;$array1[] = 60;$array2[57] = 'one';$array2[58] = 'two';$array2[59] = 'three';$array2[60] = 'four';?> I want to select from array2 those values where key in array2 is equal to value in array1. Is this possible?Thanks in advanced Link to comment Share on other sites More sharing options...
smartalco Posted June 8, 2007 Share Posted June 8, 2007 i believe you could do something like this <?php$array1[] = 57;$array1[] = 60;$array2[57] = 'one';$array2[58] = 'two';$array2[59] = 'three';$array2[60] = 'four';$variable = $array2[$array1[1]];?> substituting the second 1 in "$array1[1]" for the key of the value you want to use from array 1your welcome in advance Link to comment Share on other sites More sharing options...
dhimo Posted June 8, 2007 Author Share Posted June 8, 2007 Yeah mean, thanks I got the idea. Like this foreach ($array1 as $val) { echo $array2[$val] . "<br />";} Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.