As already mentioned, creating such an array is not possible, but you can do something like this:
$words = array( 'love', 'home', 'google', 'money' ); $numbers = array( 111, 222, 333, 444, 555, 666, 777, 888 ); $result = array(); foreach($words as $word){ $result[$word] = array(); } $wordsmax = count($words) - 1; foreach($numbers as $number){ $result[$words[rand(0,$wordsmax)]][] = $number; }
This might output something like:
Array ( [love] => Array ( [0] => 222 [1] => 888 ) [home] => Array ( [0] => 555 [1] => 666 [2] => 777 ) [google] => Array ( [0] => 333 ) [money] => Array ( [0] => 111 [1] => 444 ) )
source share