Here, we should note that the methods for returning a single result include find, getBy, and so on. The following is a demonstration result based on an official example.
Looping array structure
| The code is as follows: |
Copy code |
Array (2 ){ [0] => array (8 ){ ["Id"] => string (2) "33 & Prime; ["Title"] => string (6) "222111 & Prime; ["Content"] => string (6) "222111 & Prime; ["User_id"] => string (1) "0 & Prime; ["Create_time"] => string (10) "1342800330 & Prime; ["Update_time"] => string (1) "0 & Prime; ["Status"] => string (1) "1 & Prime; ["Email"] => string (12) "222111@1.com" } [1] => array (8 ){ ["Id"] => string (2) "32 & Prime; ["Title"] => string (6) "654364 & Prime; ["Content"] => string (5) "adlkf" ["User_id"] => string (1) "0 & Prime; ["Create_time"] => string (10) "1342800285 & Prime; ["Update_time"] => string (1) "0 & Prime; ["Status"] => string (1) "1 & Prime; ["Email"] => string (9) "222@1.com" } } One-dimensional arrays that cannot be recycled Array (8 ){ ["Id"] => string (2) "10 & Prime; ["Title"] => string (1) "6 & Prime; ["Content"] => string (1) "6 & Prime; ["User_id"] => string (1) "0 & Prime; ["Create_time"] => string (10) "1342627991 & Prime; ["Update_time"] => string (1) "0 & Prime; ["Status"] => string (1) "1 & Prime; ["Email"] => string (7) "1@1.com" } |
Postscript
Date: 2012-Oct-9th
If you want to convert a variable to ThinkPHP cyclically,
In terms of principle,
You only need to convert a one-dimensional array into a two-dimensional array,
Below are some simple steps
| The code is as follows: |
Copy code |
<? Php // Suppose we have a one-dimensional array variable $ unloop // Convert $ unloop to a two-dimensional array $ Enloop = array (); $ Enloop [0] = $ unloop; // $ Enloop is an array that can be recycled by ThinkPHP. ?> |
Foreach label
The foreach tag does not have as many functions as the volist tag. The advantage is that it can traverse and output objects, while the volist tag is usually used to output arrays.
Example:
| The code is as follows: |
Copy code |
<Foreach name = "list" id = "vo"> User Name: {$ vo. username} <br/> Email: {$ vo. email} <br/> Registration time: {$ vo. regdate | date = "Y-m-d H: I ",###} <Hr/> </Foreach> |