skyer2000 Posted May 7, 2009 Share Posted May 7, 2009 I've pulled two strings from my database: keyid = (1,5,7) keyword = (foo1,foo2,foo3) I can convert them to their own arrays by using the explode function, however, the array is: array(0 => foo1, 1 => foo2, 2 => foo3); When I need it to match the keyid for each keyword: array(1 => foo1, 5 => foo2, 7 => foo3); How do I combine them like that? Quote Link to comment Share on other sites More sharing options...
Jibberish Posted May 7, 2009 Share Posted May 7, 2009 if you do something like <?php $keyid = '1,5,7'; $keyword = 'foo1,foo2,foo3'; $keyid_array = explode(',' , $keyid); $keyword_array = explode(',' , $keyword); $combined_array = array_combine($keyid_array, $keyword_array); print_r($combined_array); ?> I think that should give you the result you want. Quote Link to comment Share on other sites More sharing options...
skyer2000 Posted May 7, 2009 Author Share Posted May 7, 2009 Thanks! I knew there had to be a function for that... Quote Link to comment Share on other sites More sharing options...
messer Posted May 7, 2009 Share Posted May 7, 2009 and it works even with 3 arrays??? Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 7, 2009 Share Posted May 7, 2009 Well the function works with 2 at a time, but you can apply it again and again for more. 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.