473,387 Members | 1,502 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How do I change for toy,boy,etc?

1
Expand|Select|Wrap|Line Numbers
  1. <?php
  2.     echo "Enter the number of nouns you like to change its plural: ";
  3.     $f = fopen("php://stdin","r");
  4.     $num = rtrim(fgets($f));
  5.     $input = array($num);
  6.     function Change_Plural($noun)
  7.     {
  8.         switch (true)
  9.         {
  10.             case (substr($noun,-1) == 's'):
  11.             case (substr($noun,-2) == 'sh'):
  12.             case (substr($noun,-2) == 'ch'):
  13.             case (substr($noun,-1) == 'o'):
  14.             case (substr($noun,-1) == 'x'):
  15.                  echo $noun.'es'."\r\n";
  16.                  break;
  17.             case (substr($noun,-1) == 'f'):
  18.                  echo substr_replace($noun,'ves',-1)."\r\n";
  19.                  break;
  20.             case (substr($noun,-2) == 'fe'):
  21.                  echo substr_replace($noun,'ves',-2)."\r\n";
  22.                  break;
  23.             case (substr($noun,-1) == 'y'):
  24.                                            {
  25.                                                switch(true)
  26.                                                {
  27.                                                    case (substr($noun,-2) != 'ay'):
  28.                                                 case (substr($noun,-2) != 'ey'):
  29.                                                 case (substr($noun,-2) != 'iy'):
  30.                                                 case (substr($noun,-2) != 'oy'):
  31.                                                 case (substr($noun,-2) != 'uy'):
  32.                                                      echo substr_replace($noun,'ies',-1)."\r\n";
  33.                                                      break;
  34.                                                 default:
  35.                                                         echo $noun.'s'."\r\n";
  36.                                             }
  37.                                            }
  38.                                            break;
  39.             default:
  40.                     echo $noun.'s'."\r\n";
  41.         }
  42.     }
  43.     for ($j = 0; $j < $num; $j++)
  44.     {
  45.         $input[$j] = rtrim(fgets($f));
  46.     }
  47.     echo "\r\n";
  48.     for ($j = 0; $j < $num; $j++)
  49.     {
  50.         Change_Plural($input[$j]);
  51.     }
Aug 18 '15 #1
0 1003

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: J.C. Flores | last post by:
Hello all, First of all, I must state that I'm new to SQL Server, but have been a long-time software guy for quite some time. Please excuse the potential simplicity of the solution to my...
1
by: Spike | last post by:
Hello! Im going to make a javascript for changing alot of images. But im not sure how to do it., where to start.. Ok, first.. this is the isue. I have 3 images(I call them 1a-3a). when u...
0
by: beanweed | last post by:
BACKGROUND ---------- I have an ASP.NET application having two panels. In one panel, an XML document, transformed using xsl, is displayed. In the other panel are some controls that allow a user...
5
by: Hank | last post by:
My Access 2000 code has been running for several years in our main plant. Now we need to install it, as a stand-along application, at remote sites, some of which are out of state. My problem is...
10
by: Fabrizio | last post by:
(Sorry for the crosspost, but I really don't know which is the right newsgroup!) Hi all, I try to change the password to a user that as to change the password at first logon: try {
4
by: active | last post by:
It appears to me that if I change the Control's client size the controls size does not change to agree with the new size. Does it work like the VB6 ScaleWidth and ScaleHeight? That is after I...
3
by: Tom | last post by:
I am writing a Visual basic .Net database application. There are many forms that first let you select and look at a DB record and then when you click a "modify" button you are allowed to change...
2
by: J | last post by:
Hello. I apologize if this isn't the appropriate group for this question but I was wondering if it's possible to allow regular windows domain users to change their passwords through an .asp page? ...
11
by: Simon | last post by:
Dear reader, The syntax for the VBA code to change the RowSource of a Master Report is: Me.RowSource = "TableOrQueryName"
1
by: monkey1001 | last post by:
my program is suppose to show my due change and i got it working but my change and coins are wrong how can i improve it thank you..(its supposed to be in java)
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.