In the '2 cents functions that bring a lot to your website' family, you can add in a general include, let's call it a library of utilities that you call from absolutely every PHP page of your website, a set of functions which purpose is to help spelling correctly when building dynamically a report.
e.g. No more "1 results have been found for your search",
but "1 result has been found for your search", or "17 results were found for your search"
The functions found in the attached file are to be included in a "utils.inc" or whatever file you put all of your helpers in, and included as a:
require_once "utils.inc";
into your files.
Remember to place utils.inc in a folder that is visible to your include_path PHP Configuration variable.
You could then use them in situations like:
$sql = sprintf("SELECT COUNT() FROM book WHERE abstract LIKE ' %s%%' OR abstract LIKE '%s %%'", $search_text, $search_text);
$result = mysql_query($sql);
$hits = mysql_num_rows($result);
printf("<div>%d result%s %s found for your search <em>%s</em></div>'",
$hits, plural_s($hits), plural_was($hits), $search_text);
// and so forth...
<?php
// ...
// excerpt from utils.inc
// ...
// everyone will like this one:
function plural_s($n) {
return abs($n) > 1 ? 's' : '';
}
//English localised website designers will like these ones: