Ask the master to interpret a small number of unlimited classification code,,,

Source: Internet
Author: User
Unlimited classification

foreach ($rows as $id = $item)
{
if ($item [' pid '])
{
$rows [$item [' PID ']][$item [' id ']] = & $rows [$item [' id ']]; This is the main part, can you explain it in detail?
$t [] = $id;
}
}


Reply to discussion (solution)

For

$rows = Array (  ' id ' = = 1, ' pid ' = 0), 2 = = Array (  ' id ' = = 2, ' pid ' = 1),  3 = > Array (' id ' = 3, ' pid ' = 2),  4 = = Array (' id ' = = 4, ' pid ' = 3),);

$rows [$item [' PID ']][$item [' id ']] = & $rows [$item [' id ']]; The role of this is


If the key of the array $rows is the same as the ID

Why does this & sign have the same effect as recursion?

For

$rows = Array (  ' id ' = = 1, ' pid ' = 0), 2 = = Array (  ' id ' = = 2, ' pid ' = 1),  3 = > Array (' id ' = 3, ' pid ' = 2),  4 = = Array (' id ' = = 4, ' pid ' = 3),);

$rows [$item [' PID ']][$item [' id ']] = & $rows [$item [' id ']]; The role of this is


If the key of the array $rows is the same as the ID
Moderators often write code like this: $sql =<< <> < p="">

<<< identifiers
Identifier

Custom identifiers, just as strings are enclosed in ",", here with the identity surround
Identifiers are naturally custom, and of course can give him a name that is close to the content.

<<< identifiers
Identifier

Custom identifiers, just as strings are enclosed in ",", here with the identity surround
Identifiers are naturally custom, and of course can give him a name that is close to the content.
Understand, Gray often thanks, but what is the effect of this writing? What is the general situation to use? I think the internet is used to escape the symbol, if so is not to avoid the safe handling function? But there are few online information.

  • 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.