# Help With Function in PHP



## Hale88 (Dec 5, 2009)

I really need help in this assignment since Function is so complicated. I only understand around 70% of it.
here is the assingment: Please write it in basic code so I can learn more and modify it later on

"Write a function called Celsius that accepts one argument for the Fahrenheit temperature and returns the value of the Fahrenheit temperature converted to Celsius.
Here is the formula to convert a Fahrenheit temperature to Celsius
C = 5 / 9 * (F – 32)
To use this function create a for loop that goes from 0 to 100.
In each iteration of the loop
• call the Celsius function passing the function the loop counter
• print the loop counter and the value returned from the Celsius function on the same line
This will create a list where the first number represents the Fahrenheit temperature and the second number represents the corresponding Celsius temperature."

thank you much


----------



## Kreij (Dec 5, 2009)

No offense, Hale88, but you really need to give it a little effort. You can write this whole thing in 4 lines of code.

I'm feeling generous this morning so here is a C# version ...

```
for (i = 0; i <= 100; i++)
{
    Console.Writeln("Fahrenheit : " + i + "    Celsius : " + Celsius(i).ToString());
}

float Celsius (int Fahrenheit)
{
    return 5 / 9 * (Fahrenheit - 32);
}
```


----------

