<?php
/**
* Total itens
*
* Com base no número recebido, devolve uma indicação
* humanamente legível sobre o total de itens.
*
* @param integer $i Número a analisar .
* return $string $html HTML pronto a utilizar.
*/
function totalItens ($i=0) {
$html = ' (nenhum)';
if ($i >= 1) {
$html = ($i == 1) ? ' (1 item)' : ' ('.$i.' itens)';
}
return $html;
}
echo totalItens(3);
PD9waHAKCi8qKgogKiBUb3RhbCBpdGVucwogKgogKiBDb20gYmFzZSBubyBuw7ptZXJvIHJlY2ViaWRvLCBkZXZvbHZlIHVtYSBpbmRpY2HDp8OjbwogKiBodW1hbmFtZW50ZSBsZWfDrXZlbCBzb2JyZSBvIHRvdGFsIGRlIGl0ZW5zLgogKgogKiBAcGFyYW0gaW50ZWdlciAkaSBOw7ptZXJvIGEgYW5hbGlzYXIgLgogKiByZXR1cm4gJHN0cmluZyAkaHRtbCBIVE1MIHByb250byBhIHV0aWxpemFyLgogKi8KZnVuY3Rpb24gdG90YWxJdGVucyAoJGk9MCkgewoKICAkaHRtbCA9ICcgKG5lbmh1bSknOwoKICBpZiAoJGkgPj0gMSkgewoKICAgICRodG1sID0gKCRpID09IDEpID8gJyAoMSBpdGVtKScgOiAnICgnLiRpLicgaXRlbnMpJzsKICB9CgogIHJldHVybiAkaHRtbDsKfQoKZWNobyB0b3RhbEl0ZW5zKDMpOw==