Skip to content

Instantly share code, notes, and snippets.

@giovannipds
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save giovannipds/6dbc11ac46d0819d60c7 to your computer and use it in GitHub Desktop.
Save giovannipds/6dbc11ac46d0819d60c7 to your computer and use it in GitHub Desktop.
Links separados vírgula e "e" em PHP
<?php $length = 6; // apenas para exemplo ?>
<?php for ($i = 0; $i < $length; $i++) { ?>
<a>Elemento</a><?php if ($i + 1 !== $length && $i + 2 !== $length) { ?>,<?php } else if ($i + 2 === $length) { ?> e <?php } else if ($i + 1 === $length) { ?>.<?php } ?>
<?php } ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment