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!