How to combine these two array into one array using php? -
this question has answer here:
- merge 2 arrays key value pairs in php 3 answers
given these 2 array:
$name=array("alice","ken","wendy"); $frequent=array(3,6,9);
i try combine like
$data = array($name=>$frequent);
but fails. can help?
i want this:
$data = array( 'alice' => 3, 'ken' => 6, 'wendy' => 9, );
you can use array_combine
$combined_array = array_combine($name, $frequent);
documentation here: http://php.net/manual/en/function.array-combine.php
Comments
Post a Comment