PHP Code:
<?php
$lastUpdate = date( 'j F Y', filemtime( 'pageContent/test.txt' ) );
?>
<?php
$result = 01234; // TESTING TESTING TESTING
function cardinalNumber($test_number, $result) { // TESTING TESTING TESTING
//function cardinalNumber($_SESSION["limit"], $result) {
/*****************************************************************************************************
*
* INPUT: ANY POSITIVE INTEGER
*
* RETURNS: RESULT
*
* REFERENCE: https://www.php.net/manual/en/langref.php
*
* REMARKS: Two ways to do this occur to me. The first way is to convert the input integer to a string and then extract
* each digit, one at a time. Each extracted digit is then individually converted back to numeric form.
* We call this the "brute force" method. The second way is to arithmetically compute each digit.
*
* Door Two is, oh, so much more elegant. This function uses door two.
*
******************************************************************************************************/
// Part Zero: Definitions
$numbers = array (
"",
"one",
"two",
"three",
"four",
"five",
"six",
"seven",
"eight",
"nine",
"ten",
"eleven",
"twelve",
"thirteen",
"fourteen",
"fifteen",
"sixteen",
"seventeen",
"eighteen",
"nineteen"
);
$decades = array (
"", // aughts
"", // tens
"twenty",
"thirty",
"forty",
"fifty",
"sixty",
"seventy",
"eighty",
"ninety"
);
// [obtain/retrieve $argument]
// $argument = min($_SESSION["limit"], 9999); // commented for testing purposes only // are you kidding me?
$argument = $test_number; // TESTING TESTING TESTING
$argument = 8765; // TESTING TESTING TESTING
$argument = min($argument, 9999); // TESTING TESTING TESTING
// Part One: Determine place values: thousands, hundreds, tens, units
$working_number = $argument; // bring the bu, bu, bucket down
$thousands = ($working_number / 1000) - (($working_number % 1000) / 1000); // ditch remainder, for pure thousands
var_dump ("Debug", $thousands);
$working_number = $working_number - (1000 * $thousands); // ditch thousands
$hundreds = ($working_number / 100) - (($working_number % 100) / 100); // ditch remainder, for pure hundreds
$working_number = $working_number - (100 * $hundreds); // ditch hundreds
$tens = ($working_number - ($working_number % 10) / 10); // ditch remainder, for pure tens
$units = ($working_number - (10 * $tens)); // ditch tens, for units
//
// Part Two: Construct Result
//
// Determine Thousands
$result = $numbers ($thousands);
if ($thousands != 0) {
$result = $result . " thousand";
}
// Determine Hundreds
$result = $result . $numbers ($hundreds);
if ($hundreds != 0) {
$result = " " . $result . " hundred";
}
// Determine Tens and Units
$result = $result . $decades ($tens);
if ($tens > 1) {
$result = $result . " " . $decades ($tens);
if ($units) {
$result = $result . "-" . $units;
}
else {
$result = $result . " " . $numbers ((10 * $tens) + $units);
}
}
//
// Part Three: Return Result//
//
echo $result; // TESTING TESTING TESTING
return $result;
}
echo "<br />";
echo "<br />";
echo "<br />";
echo "<br />";
echo "testing connection from line 132 of test function <br />";
cardinalNumber(5432, $result);
?>
This is line 135 of test.txt.
<br />
<br />
<br />
<br />
Can y'all help me?
Bookmarks