Tuesday, May 26, 2020

Ordinal Numbers in PHP

A simple program that I wrote to demonstrate ordinal numbers using PHP programming language.

I am currently accepting programming work inventory system, enrollment system, accounting system, payroll system, information system, website design and development using WordPress, IT projects, school and application development, programming projects, thesis, and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me in the following email address for further details. If you want to advertise on my website kindly contact me also in my email address also. Thank you.

My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.My mobile number here in the Philippines is 09173084360. My telephone number at home here in Bacolod City, Negros Occidental Philippines is +63 (034) 4335675.

Here in Bacolod City, Negros Occidental I also accepting computer repair, web development using WordPress, Computer Networking, and Arduino Project development at a very affordable price. My personal website is http://www.jakerpomperada.com

My programming website is http://www.jakerpomperada.blogspot.comI am also a book author you can purchase my books on computer programming and information technology in the following links below.
https://www.unlimitedbooksph.com/



Sample Program Output


Program Listing

index.php


<html>
  <head>
    <title>Ordinal Numbers in PHP </title>
  </head>
  <style type="text/css">
    body {
      font-family: arial;
      size: 15px;
    }
  </style>
 <body>
  <h2> Ordinal Numbers in PHP </h2>
<?php

  function OrdinalNumberSuffix($num) {
    if (!in_array(($num % 100),array(11,12,13))){
      switch ($num % 10) {
        // Handle 1st, 2nd, 3rd
        case 1:  return $num.'st';
        case 2:  return $num.'nd';
        case 3:  return $num.'rd';
      }
    }
    return $num.'th';
  }


for ($i = 1; $i <= 255; $i++){
  echo OrdinalNumberSuffix($i) . "\t";
  if ($i % 10 == 0) {
    echo "\n";
  }
}

?>
</body>
</html>

No comments:

Post a Comment