PHP simple two-table merge into the new table implementation process

Source: Internet
Author: User
Tags php class
In our daily development work, we have to deal with the database and data tables, we usually encounter multi-table query, table query, and two tables merge and then produce a new table and so on, today we will introduce a simple PHP simple two tables merged into a new table class, the 2 tables into 1 tables, and orderly arrangement of methods, involving the array of traversal and sequencing operation skills, has a certain practical value!

The first step is to first download the PHP simple two tables we need to use in this lesson to merge into the new Table class library: http://www.php.cn/xiazai/leiku/540

The second step, after the download, find the PHP class files we need, unzip to our local directory, create a new PHP file!

After the third step, we will call this class in the new PHP file, and instantiate the class:

<?phpinclude_once "biao.php";  Introduce class file  $phpig = new Union ();   Instantiate class  $lista = $phpig->lista = Array (3, 5, 8, one);  $listb = $phpig->listb = Array (2, 6, 8, 9, one, and up);  $LISTC = $phpig->listc;  $lena = $phpig->getlenght ($lista); Get table size  $lenb = $phpig->getlenght ($LISTB);  $i = $j = 0;  while ($i < $lena && $j < $lenb) {    $ea = $phpig->getelement ($lista, $i);    $eb = $phpig->getelement ($LISTB, $j);    if ($ea <= $eb) {      $LISTC = $phpig->listinsert ($LISTC, $ea);      + + $i;    } else {      $LISTC = $phpig->listinsert ($LISTC, $eb);      + + $j;    }  }  while ($i < $lena) {    $ea = $phpig->getelement ($lista, $i);    $LISTC = $phpig->listinsert ($LISTC, $ea);    + + $i;  }  while ($j < $lenb) {    $eb = $phpig->getelement ($LISTB, $j);    $LISTC = $phpig->listinsert ($LISTC, $eb);    + + $j;  }  Print_r ($LISTC);? >

Run the file and get the results as shown:

Related Article

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.