How to find the end element of an array using end()

Little working code to understand array_sum() and end() functionality —

<code>
<?php

$a = array(1,5,8,0,4,3);

$b = array_sum($a);

if($b < end($a))
{
$c = end($a)+ ($b/2);
echo $c;
}
else
{
?>
</code>

Advertisements
Posted in PHP

Leave a Reply

Please log in using one of these methods to post your comment:

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