AcronymIT PHP class - v1.0

Waht the class does - Main features

Functions in the class


function acronym($text, $link = 0, $lang = "en")

@param string $text the text to scan for acronyms
@param bool $link if set, prints also the link to Wikipedia
@param string $lang the language of the Wikipedia portal to link
@return string the new text with the acronyms

Looks for the known (and most common) acronyms in the text and make them HTML acronyms (so they'll have the acronym tag).


function list_acronyms($limit = -1)

@param int $limit how many acronyms do you want to print?
@return void

Lists acronyms stored in the selected file


function set_file($file)

@param string $file the file path
@return void

Sets the file where acronyms are stored in


function add_acronym($acronym, $definition)

@param string $acronym the acronym to add
@param string $definition what does the acronym mean?
@return bool true on success

Adds the specified acronym to the file set before through the set_file() method


function rm_acronym($id)

@param int $id the id of the acronym to remove
@return bool true on success

Deletes the specified acronym from the file set before through the set_file() method

Examples of use

Example #1

The following code will find all the acronyms in the text passed to the method and will link to the italian version of Wikipedia for further explanations

$text = "The PHP version 6 is under development. Read more on the WWW or get info via RSS";
$acronymit = new AcronymIT();
$text = $acronymit->acronym($text, 1, "it");
echo $text;

Example #2

Listing acronyms stored in the default file, then in another one


$acronymit = new AcronymIT();
echo "File $acronymit->file:"; // Will be "FIle acronyms.dat:"
$acronymit->list_acronyms(5); // Lists the first 5 acronyms in the default file

$acronymit->set_file("path/to/other_acronyms.txt"); // Changing the file

echo "File $acronymit->file:"; // Will be "File path/to/other_acronyms.txt:"
$acronymit->list_acronyms() // Lists all the acronyms in the file

echo "Done! ;)";

Example #3

Adding, removing acronyms and changing definitions


$acronymit = new AcronymIT();

$acronymit->add_acronym("LOL", "Lough Out Loud");
$acronymit->list_acronyms(); // Default file with LOL, Laugh Out Loud added

$acronymit->list_acronyms(); // Default file without LOL, Lough Out Loud

$acronymit->add_acronym("LOL", "Lot Of Laughs");
$acronymit->list_acronyms(); // Default file with LOL, Lot Of Laughs added

$acronymit->list_acornyms(); // Changing the file: LOL does not exist now

$acronymit->add_acronym("LOL", "Laugh Out Loud");
$acronymit->list_acronyms(); // So let's add it again to the new file!


No changes made since now.


Copyright (C)2007 Giulio Bai

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License v2 as published by the Free Software Foundation.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

A copy of the full license can be found in the official GNU's site



Plase share it!

If you found this program useful, share it! Maybe it can help also other people!
Don't be scared, it's free, editable, redistributable.
So... share, Share, SHARE!


If you want to know more about this program, you can contact me at
Wht do you think about this program? Is it useful? How can be improved?