PHP Basic Programs
PHP Basic Programs PHP Basic Programs These are some of the Basic Programs written in PHP 1.Sum of elements of an array 2.Average of elements of array 3.Largest element in array 4.Smallest element in array 5.To convert digit to word 6.Function to swap two numbers using call by reference 7.Function to return sum of digits 8.Function to print arrays in reverse order 9.Function to return reverse of digits entered by parameter 10.Function to check number is even or odd 11.Function to check number is prime or not 12.Function to find power of a number entered by parameter. 13.Function to check whether the given number is palindrome or not 14.Function to convert decimal number to binary number 1. Program to find sum of elements of an array <?php $a = array (1,2,3,4,5); $sum=0; $i=0; for($i=0;$i<(count($a));$i++) { $sum=$sum + $a[$i]; } echo ("Sum of elements is:" . $sum); ?> Output: Sum of elements is:15 2. P