Php merge array array_merge function application instance-PHP source code

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.