Thank you for your enthusiastic reply. Sorry, I didn't make it clear when I described the problem, which delayed your time. For example, the word "Chongqing", because the word "heavy" is a multi-tone word, reads: C, Z; and "Qing: Q should combine all the pronunciations: CQ, ZQ, "...
Thank you for your enthusiastic reply. Sorry, I didn't make it clear when I described the problem, which delayed your time.
For example:
The word "Chongqing", because the word "heavy" is a multi-tone word, reads: C, Z; and the word "Qing", reads: Q to combine all the pronunciations: CQ, ZQ
So,
In this case, the CQC, ZQC, CQZ, and ZQZ pronunciation should be combined.
Then more words are combined into more combinations.
How can this problem be achieved?
$arr = array('a','b');$single = array('c','b');function merge(){ $arg = func_get_args(); $r = array(); if(0 < count($arg) && is_array($arg[0])){ $base = $arg[0]; foreach ($arg as $k => $v) { if($k > 0 && is_array($v)){ foreach($base as $sk=>$sv){ foreach ($v as $tk => $tv) { array_push($r, $sv.$tv); } } } } if(0 < count($r)){ return $r; }else{ return !1; } }else{ return !1; }}var_dump(merge($arr, $single));
Reply content:
Thank you for your enthusiastic reply. Sorry, I didn't make it clear when I described the problem, which delayed your time.
For example:
The word "Chongqing", because the word "heavy" is a multi-tone word, reads: C, Z; and the word "Qing", reads: Q to combine all the pronunciations: CQ, ZQ
So,
In this case, the CQC, ZQC, CQZ, and ZQZ pronunciation should be combined.
Then more words are combined into more combinations.
How can this problem be achieved?
$arr = array('a','b');$single = array('c','b');function merge(){ $arg = func_get_args(); $r = array(); if(0 < count($arg) && is_array($arg[0])){ $base = $arg[0]; foreach ($arg as $k => $v) { if($k > 0 && is_array($v)){ foreach($base as $sk=>$sv){ foreach ($v as $tk => $tv) { array_push($r, $sv.$tv); } } } } if(0 < count($r)){ return $r; }else{ return !1; } }else{ return !1; }}var_dump(merge($arr, $single));
Use a function:
The meaning of your image: a large array contains two small arrays, and now the third array is given, which is combined into each small array of the large array.
Implementation principle:
Array merging and returning a new array function: array_merge ().
Function merge ($ a1, $ a2, $ a3 ){
$ Result = array ();
$ T1 = arrar_merge ($ a1, $ a3 );
$ T2 = arrar_merge ($ a2, $ a3 );
$ Result [] = $ t1;
$ Result [] = $ t2;
Return $ result;
}
$item) { $arr[$key][0] = $arr[$key][0].$single[0]; } var_dump($arr);
$ Answer = array_map (function ($ subArray) use ($ third) {return array_merge ($ subArray, $ third) ;}, $ first );
Do not blame?