Simple example of PHP linked list operation

Source: Internet
Author: User
Tags php website
This article mainly introduces the PHP linked list operation, analyzes the definition and usage skills of the php linked list in the form of simple instances, and has some reference value, for more information about PHP linked list operations, see the example in this article. We will share this with you for your reference. The details are as follows:

Running the data structure in php is basically simulated by arrays, but it is always thought.

The problem today is that the two linked lists are merged.

Is Linked List B longer than linked list?

Programming is to list as many possibilities as possible. Catch the variable. as required by the question, when the linked list and the B linked list are equal, the B linked list is directly returned, so you do not need to consider this issue.

$ Node = array ("nameid" => "", "shoolid" => "", "depid" => "", "start" => "", "end" => "");/* if the preceding data exists, some data exists in linked list A, and some data exists in linked list B. if none exist, use the data node of the linked list instead. At the first time, I thought of a very painful way and used the arra_diff () function to make a difference using this linked list. Later, I thought about it carefully. * /// $ Data indicates the B linked list // $ time indicates the linked list // to save resources, the third linked list is not opened, but operated in the B linked list, why do you need to select a chain table with uncertain length? // you will know why if (empty ($ data) // {// apply for a node $ data = array (); foreach ($ time as $ value) {// process the data in the linked list as required, the node mode $ array = array ("nameid" => $ value ["id"], "depid" => $ depid, "schoolid" => $ schoolid, "start" => "", "end" => ""); array_push ($ data, $ array ); // Press the new node into the stack} else if (count ($ data) <= count ($ time) // compare the length {for ($ I = 0; $ I
 
  
$ Time [$ I] ["id"], "depid" => $ depid, "schoolid" => $ schoolid, "start" => "", "end" => ""); array_push ($ data, $ array );}}}
 

The above algorithm is A simple practice. it combines the data of A linked list with the data of B.

I hope this article will help you with PHP programming.


For more articles on simple examples of PHP linked list operations, refer to the Chinese PHP website!

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.