How can stop foreach dublicate values in smarty 2? -


Hello, I have the consequence of how to prevent sharing the same values ​​after the foreclosure on the template and only Can one show the same?

  & lt; Ul & gt; {Foreach = $ names item = v name = thenames} Lt; Li & gt; {$ v.names} / & lt; Li & gt; {/ Foreach} & lt; / Ul & gt;    

If this is a simple key-gt; If the value is array, you can use it in your php file before processing the array before sending it to the file if you have duplicate one after the other (ie, A, A, A, B, B, C, C, C) can also call within the template, so you can do $ name. With array_unique

Try using a variable to store the previous value, so it only shows first:

  {assign var = "previous" value = ""} {$ = $} Items = forename = v name = thenames} {if $ last! = $ v.names} 
  • gt; {$ v.names} / & lt; Li & gt; {/ If} {Assign var = "previous" value = $ v.names} {/ foreach}

    If not, then I have already pre-compressed in php or using smarty3 I advise.

  • Comments

    Popular posts from this blog

    php - PDO bindParam() fatal error -

    logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

    java - Why my included JSP file won't get processed correctly? -