In today's work, we need to first check whether there are 6 data records that meet the conditions in the specified database. If the data in Table B is not found in Table 6-A, then the array is merged, let me share with you the entire process. In today's work, we need to first check whether there are 6 data records that meet the conditions in the specified database. If the data in Table B is not found in Table 6-A, then the array is merged, let me share with you the entire process.
Script ec (2); script
We can use the array_merge function to merge arrays in php.
Array array_merge (array array1 array2 ..., ArrayN)
Example
| The Code is as follows: |
|
// Group buying 1 $ T = 1; $ Tugou = esf ("*", "setindex = '1' $ cwhere order by id desc limit 0, 6", "Table "); Foreach ($ tugou as $ v =>$ _ v) { $ Tugou [$ v] ['I'] = $ t ++; } $ Abpccount = count ($ tugou ); // Echo $ abpccount; If ($ abpccount <6) { $ Page-> tpl-> assign ('notg ', 1); // call the Group Buying tag $ Abpclimit = 6-$ abpccount; $ Tugou_loupan = esf ("*", "index_dt = '1' $ cwhere order by id desc limit 0, $ abpclimit", "B Table "); Foreach ($ tugou_loupan as $ v =>$ _ v) { $ Tugou_loupan [$ v] ['I'] = $ t ++; $ Tugou_loupan [$ v] ['abpcindexpic '] =_ _ v ['abpcthumb']; $ Tugou_loupan [$ v] ['abpclitpic '] =_ _ v ['abpcthumb']; $ Tugou_loupan [$ v] ['abpcname'] = mt_rand (10, 80 ); $ Tugou_loupan [$ v] ['abpclow'] = 'xx hui '; $ Tugou_loupan [$ v] ['abpclpname'] =$ _ v ['abpcname']; } $ Tugou = array_merge ($ tugou, $ tugou_loupan ); } $ Page-> tpl-> assign ('tugou', $ tugou ); |
Notes
When merging array_merge (), we must note that the intermediate value must be an array. Otherwise, null will be returned after merging. This is our experience.