LuchoWiki

Cosas que debería hacer más a menudo

User Tools

Site Tools


t:units

<phpwikify> /* convierte @1@ unidades de @2@ a la medida de @3@ usando “units” */ $units_bin='/usr/bin/units'; $params = array ( “@1@”, “@2@”, “@3@”); if ($params[0] == '@' . '1@' || false === $params[0]) {

echo "**Error**";
}

else {

$estring = "$units_bin -t '@1@ @2@' '@3@'";
$inp     = array();
$result  = '';
//echo "<nowiki>$estring</nowiki> ";
exec($estring, $inp);
if (empty($inp) ) $result= 'N/A';
else $result = trim($inp[0]);
// at this point $result contains the information we want
$conversion= '<html><span class="units" title="'.$result.' @3@"></html>@1@ @2@<html></span></html>';
echo $conversion;

} </phpwikify>

t/units.txt · Last modified: 20100316 15:28 (external edit)