Tuesday 15 June 2010

php - Combine/Mix two lists of words -



php - Combine/Mix two lists of words -

i have 2 lists of words in 2 arrays

first array

array ( [0] => make [1] => break [2] => buy )

second array

array ( [0] => home [1] => car [2] => bike )

and want display possible combinations create sure first array first word , 2nd array sec word:

the above 2 arrays should display next list:

make home create car create bike break home break car break bike purchase home purchase car purchase bike

thank in advance.

hi saikios, reply.

this have seems similar have posted:

$list1 = array("make","break","buy"); $list2 = array("home","car","bike"); for($a=0; $a<3; $a++){ for($b=0; $b<3; $b++){ echo($list1[$a].$list2[$b]); echo("<br />"); } }

just wondering if there improve way. both of lists have 200 words.

for right reply need know trying or how,

but solution problem simple as

<?php $array1 = array("make", "break", "buy"); $array2 = array("home", "car", "bike"); foreach ($array1 $i => $value) { foreach ($array2 $j => $value2) { echo $value.' '.$value2.'<br />'; } } ?>

php arrays

No comments:

Post a Comment