3
$arr1 = array('001','002','003');
$arr2 = array('aaa','bbb','ccc');

//$result = join $arr1 and $arr2;

I want $result such that $arr1 value becomes index of $result and $arr2 become value of each index of $result. Final result should be

$result = array("001"=>"aaa","002"=>"bbb","003"=>"ccc");

1 Answer 1

8

Use array_combine. Example:

array_combine($keys,$values)

for your question

try

$result = array_combine($arr1,$arr2);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.