I'd like to know if there is a neat way to convert 1/2, 1/4, 5/8
into words (half, quarter, five eighths
) using PHP.
I've got a product data feed, and need to create a clean URL for each product based on the name. Some have measurements like 1/4" and currently I swap out any non letter/numbers leaving me with "14" in this case. It would be more useful to convert this fraction into "quarter".
When we write the fraction in words, we use a hyphen between the cardinal number and the ordinal number. Here are some examples: We pronounce 1/3 as one-third, 1/4 as one-fourth, and 1/8 as one-eighth.
Rule: Always spell out simple fractions and use hyphens with them. Example: One-half of the pies have been eaten. Rule: A mixed fraction can be expressed in figures unless it is the first word of a sentence. Example: We expect a 5 1/2 percent wage increase.
Fractions as Words For instance, we would write “2/3” as “two thirds”: He ate two thirds of the pizza by himself! This applies for most fractions.
No, there is no neat way to do this.
You'll need to
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With