With a For loop and a while loop, you can read any number from the keyboard, input 0 automatically jumps out of the infinite loop, and determines that there are several negative numbers.Infinite loops for 1.for loops:1 ImportJava.util.Scanner;//referencing the scanner class for reading keyboard input2 classTestxunhuan3 {4 Public Static voidMain (string[] args)5 {6 inta=0;//record number of positive numbers7 intb=0;//record num
Realize infinite Pole column classification idea: Get the self-increment ID (that is, the parent ID) and then get the child ID (that is, the UID sub-ID) data to the database as followsId:1 uid:0 I am the column 1Id:2 uid:1 I am the column 2Id:3 Uid:1 I'm a subclass of column 1 Show Results:I am the column 1I'm a subclass of column 1.I am the column 2 $query = $this->db->query ("Select * from category");$list = $query->result ();foreach ($list as $v)
This article provides a detailed analysis of the implementation algorithm of php's left and right value infinite classification. For more information, see
This article provides a detailed analysis of the implementation algorithm of php's left and right value infinite classification. For more information, see
I. IntroductionIn terms of product classification, Hong Kong servers, multi-level tree-struct
We know that many open source software's infinite classification is the recursive algorithm, but we know that recursion is a waste of time, but also a waste of space (memory),
Last time I also shared a my own original infinite classification spanning tree method, a enthusiastic php expert netizens gave me a valuable advice, I tested it, this code of time very short reference: http://www.oschina.net/code/sni
First, preface
A simple description, the practice of a few principles, thinking, actually write a lot of things, thought is the most important.
1, Target: Will write an infinite node tree directory structure, such as
Steps:
1, your download plugin ztree. And then decorate it in your project.
2. Related CSS
The above CSS and JS to your own prevail.
3. Directory Structure div
4, the code of their own separate JS
The relevant functions and configur
$result [] = $row;//assigns the array to $result getList ($row [' id '], $result, $SPAC);//Recursive Call, Call yourself this argument in parentheses and above getlist ($pid =0 ...) is the same as $row[' id ']== $pid =0; } return $result;//Returns the result} $rs = GetList ();//Use Method Var_dump ($RS);//Print method result
The above infinite classification uses the recursive algorithm, the recursive algorithm simple explanation
What this article brings to you is about how PHP implements infinite pole classification. (with code), there is a certain reference value, the need for friends can refer to, I hope to help you.
In the writing of the project to use the infinite pole classification, because of the special reasons for the project, the menu bar needs to call the method multiple times, with static variables to save the array wh
This article mainly introduces the method of PHP infinite pole classification, the interested friend's reference, hope to be helpful to everybody.
The code is as follows:
If it's with smarty,Add one more
The code is as follows:
$smarty->assign (' Wuxian_class ', $AA);
Add this sentence to the HTML page.
Another issue to note is that $STR must be global, otherwise there will be an error.
Extension of infinite
This article mainly introduces the creation of PHP Infinite-level Tree menu, the main use of recursive functions, interested in the small friends can refer to
Write recursive functions, you can consider caching, define some static variables to save the results of the last run, multi-program run efficiency is very helpful.The approximate steps are as follows :Step1: take data to a database, put it into an array,Step2: Converts the data into a tree-sha
First on
Top class classification is actually a first-class classification, two-level classification is also called sub-classification classification, on this basis, sub-classification can also have sub-classification, which constitutes an infinite pole classification.
Next look at the implementation of the Code:
First, in the Controller by the field query, query out all the classification information (ID: The ID value of the classification, Cate_n
. /admin/includes/category.class.phpd) Display all product classification information in the template. /admin/templates/category_list.html4. Infinite class Classification: In category class, the data is processed infinitely. /admin/includes/category.class.php5. Use the Level property to determine the indentation information for the current product classification. /admin/templates/category_list.htmlAdd Product Categories1. Add an entry that adds a prod
today, a netizen has a problem:give the following parent-child structure (you can describe it in a similar structure in your language, the first column is the parent, the second column is the child), and comb it into a similar hierarchical parent-child structure. Origin= [('A112','A1122'), ('A','A1'), ('A','A2'), ('A1','A11'), ('A2','A21'), ('A2','A22'), ('A','A3'), ('A22','A221'), ('A11','A111'), ('A21','A211'),
How can I use return to traverse infinite arrays? Lt ;? Php $ arr = array (6, 66), 8); functionarr_p ($ arr) { nbsp; foreach ($ arras $ v) { nbsp; if (I how to use return to traverse infinite arrays?
$ Arr = array (6, 66), 8 );
Function arr_p ($ arr ){
Foreach ($ arr as $ v ){
If (is_array ($ v )){
Arr_p ($ v );
} Else {
Echo $ v ."
";}
}
}
Arr_p ($ arr );
?>
This is a direct echo. now I want to use retu
An introduction to the problem of recursive function return values in PHP is presented in the example of Ecshop infinite classification.
When Ecshop two times in the development of Product Classification index, the classification ID to obtain the top-level classification ID. The first response is recursive, so the recursive function is written as follows:
copy code
function Getcattopid ($cat _id) { if ($ cat_id) { $r
Ignore_user_abort (1) and set_time_limit (0) then set an infinite loop. how do I terminate it? This post was last edited by zhoumengkang from 2013-08-0917: 24: 21 Today. the example in ingore_user_abort () in the manual is indeed ignore_user_abort (1) and set_time_limit (0) then I set an infinite loop. how can I terminate it?
This post was last edited by zhoumengkang at 17:24:21
The example in ingore_user_a
Topic Link: UVA 10627-infinite RaceThe main topic: a certain way. Two people go back and forth on this road to find the number of encountersProblem-solving ideas: There are two kinds of encounters, one is chase, one is relative
Pursuit:T ?(u?v)=(2?k +1)?L Relative:T ?(u+v)=(2?k +1)?L
But there is a special case. It is to be considered two times when the boundary is met, so it should be lost once.So how to consider the time when the boundar
In this paper, we describe the method of implementing Smarty template infinite Pole classification in PHP. Share to everyone for your reference, as follows:
". $n. $class _arr[$i][1]." \ n "; }else{$str. = "
". $n. $class _arr[$i][1]." \ n "; } dafenglei_select ($m +1, $class _arr[$i][0], $index); }} return $str;} $AA = Dafenglei_select (1,0,0);? >Top category
If it's with smarty,Add a Copy code code as follows: $sma
Infinite class Classification I now know that the bottom node is known
Find all the parent nodes in one way! Thank you
Reply content:
Infinite class Classification I now know that the bottom node is known
Find all the parent nodes in one way! Thank you
If you are asking how to use an SQL statement to find all the parent nodes, join may be possible, but it is not recommended to use a database im
There are roughly three ways to categorize PHP indefinitely,
1, the database by setting the parent class ID to make a unique index, and then use the recursive invocation of the function to achieve infinite classification;
2, the database design is arranged in a specific format, and then use the MySQL query key function: Concat. Program implementation is relatively simple;
3, the third is not too understanding, as if to use the algorithm and data stru
An array to achieve an infinite class classification of PHP class program, there is a need for friends to refer to, here is not much to say what is directly copied on the code.
The code is as follows
Copy Code
$cates = Array (Array' CID ' = 1,' CNAME ' = ' news ',' pid ' = 0),Array' CID ' = 2,' CNAME ' = ' notice ',' pid ' = 0),Array' CID ' = 3,' CNAME ' = ' domestic News ',' PID ' = 1),Array' CID ' = 4,' CNAME ' = '
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.