コード例 #1
0
ファイル: exercise2.php プロジェクト: raynaldmo/php-education
function convertNumber($values)
{
    $originalNumber = $values["number"];
    if (is_numeric($originalNumber)) {
        $numerals = "Roman";
        $originalNumber = (int) $originalNumber;
        $convertedNumber = Numbers_Roman::toNumeral($originalNumber, true, true);
    } else {
        $numerals = "Arabic";
        $originalNumber = preg_replace("/[^IVXLCDM]/i", "", $originalNumber);
        $convertedNumber = Numbers_Roman::toNumber($originalNumber);
    }
    echo "<p>{$originalNumber} in {$numerals} numerals is: {$convertedNumber}.</p>";
}
コード例 #2
0
function pleac_Working_with_Roman_Numerals()
{
    // PHP offers no native support for Roman Numerals. However, a 'Numbers_Roman' class
    // is available for download from PEAR: [http://pear.php.net/package/Numbers_Roman].
    // Note the following 'include' directives are required:
    //
    //   include_once('Numbers/Roman.php');
    $roman = Numbers_Roman::toNumeral($arabic);
    $arabic = Numbers_Roman::toNumber($roman);
    // ----------------------------
    $roman_fifteen = Numbers_Roman::toNumeral(15);
    $arabic_fifteen = Numbers_Roman::toNumber($roman_fifteen);
    printf("Roman for fifteen is: %s\n", $roman_fifteen);
    printf("Arabic for fifteen is: %d\n", $arabic_fifteen);
}
コード例 #3
0
 /**
  * Process the value
  *
  * @param var $value The value to process/format
  * @return string The processed value
  * @access private
  */
 function _process($value)
 {
     return Numbers_Roman::toNumeral($value);
 }
コード例 #4
0
ファイル: Roman.php プロジェクト: orcoliver/oneye
 /**
  * A backwards compatibility alias for toNumeral()
  *
  * @access private
  */
 function toRoman($num, $uppercase = true)
 {
     return Numbers_Roman::toNumeral($num, $uppercase);
 }
コード例 #5
0
<?php

// Make the Numbers_Roman package available
require_once "Numbers/Roman.php";
// Retrieve current year
$year = date("Y");
// Convert year to Roman numerals
$romanyear = Numbers_Roman::toNumeral($year);
// Output the copyright statement
echo "Copyright &copy; {$romanyear}";
コード例 #6
0
ファイル: exercise1.php プロジェクト: raynaldmo/php-education
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  <head>
    <title>1 to 100 in Roman numerals</title>
    <link rel="stylesheet" type="text/css" href="common.css" />
  </head>
  <body>

    <h1>1 to 100 in Roman numerals</h1>
    <p>
<?php 
require_once "Numbers/Roman.php";
for ($i = 1; $i <= 100; $i++) {
    echo Numbers_Roman::toNumeral($i, true, true) . "<br />";
}
?>
    </p>

  </body>
</html>