function in PHP

In a previous post I wrote about finding average of two or more numbers. I  had done that in ASP.NET.

In that post I wrote, the original code I followed was in PHP.

Now I’m going to show the php page and the codes along with it.

First code:

  • <?php

    $scores = array(65, 32, 78, 98, 66);
    function avarager($array)
    {
    $total = 0;
    foreach ($array as $value)
    {
    $total += $value;
    echo “The total of number is :<br>” , $total , “<br>”;
    }
    if (count($array) > 0)
    {
    echo “The avarage is ” , “<h3>”, $total/count($array), “</h3>”;
    }
    }
    avarager($scores);

    ?>

Next it looks like:

Advertisements

2 thoughts on “function in PHP

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s