I wanted to save this array:

$words = array ("close","fed","house");

into :

$words_assoc = array (21=>"close",13=>"fed",15=>"house");

Recommended Answers

All 2 Replies

What is the relationship between the keys and values in the $words_assoc array?

Member Avatar for diafol

You give so little info, it's very difficult to know how you want to achieve this. However, if you have an array of keys and an array of values, you can do this:

$words = array("close","fed","house");
$keys = array(21,13,15);
$words_assoc = array_combine($keys, $words);
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.