PHP Template Function: last Print

  • 0

Description:

Returns either true or false based on whether or not a key in an array is the last element.

Common Location:

/cms_admin/phptemplate/<templatefolder>/functions/standard.tpl

Usage:

<?php
  $names = ["Anne", "Beth", "Carol", "Denise"];

  foreach($names as $key => $name)
  {
    echo $name;
    if (!last($sets, $key)) echo ", ";
  }

?>

In this case, a comma will be printed after each name, unless the element is the last name.

Arguments

1) The full array

2) The key of the array.

Output

Anne, Beth, Carol, Denise


Was this answer helpful?

« Back

This site uses cookies to personalize content and to analyze traffic. You consent to our cookies if you continue to use our website. Read our Privacy Policy to learn more. Please Agree or Exit