, the Smarty loop does not show

Source: Internet
Author: User
Help, Smarty Loop does not show

$arr =$_session["Mycar"];//take out a two-dimensional array from the SESSION
$smarty->assign ("arr", $arr);




{section name=a loop= $arr}

{$arr [A].pid}
{$arr [A].name}
{$arr [A].num}
Delete

{/section}


Print_r (arr) has data;
Array ([+] = = Array ([PID] + = [name] + glass coffee table [num] +-one) [+] = = Array ([PID] + [name] =&gt ; fabric sofa [num] + 6) [+] = array ([PID] + [name] + [num] = 4) [+] = array ([PID] = [Nam E] = [num] = 6))


But there's only 4 lines in the table, and it doesn't show data.
------to solve the idea----------------------
{section name=a loop= $arr} It should be possible to delete the space after this line.
------to solve the idea----------------------
{ SectionName=a loop= $arr}
Requires the subscript of the array to start at 0
You error_reporting (E_all); You'll see the error message.

$smarty->assign ("arr", $arr);
Should write
$smarty->assign ("arr", Array_values ($arr));
  • 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.