You are here: Home / Topics / Page / 2

PHP Program to check Armstrong number

By Vishal Gupta on 16 Nov 22 | Filed under: PHP
The below program checks for an Armstrong number using a loop. The PHP echo statement is used to output the result on the screen. A number is called as an Armstrong number if the sum of the cubes of its digits is equal to the number itself.Armstrong Number:abc = (a*a*a) + (b*b*b) + (c*c*c)Example: 0

PHP Program to print table of any number?

By Vishal Gupta on 16 Nov 22 | Filed under: PHP
The below program prints table of a number using a loop. The PHP echo statement is used to output the result on the screen.Example<!DOCTYPE html><html><body><?php    $num = 9;  for($i=1; $i<=10; $i++)   {$product = $i*$num;echo "$num * $i = $product" 

How to check prime number in PHP?

By Vishal Gupta on 16 Nov 22 | Filed under: PHP
The below program checks if a number is a prime or a composite number. The PHP echo statement is used to output the result on the screen.Example<!DOCTYPE html><html><body><?php$num = 13;  $count=0;  for ( $i=1; $i<=$num; $i++)  {  if (($num%$i)==0)  {

PHP Program To Print Sum Of Digits

By Vishal Gupta on 16 Nov 22 | Filed under: PHP
The below program gives the sum of two variables x and y. The PHP echo statement is used to output the text and sum value to the screen. In a similar way, codes can be written to get a sum of multiple variables in PHP.Example<!DOCTYPE html>
<html>
<body>
 
<?php
$txt1 

PHP Program for finding the frequency of numbers in given array

By Shyam Dubey on 15 Nov 22 | Filed under: PHP
This program is useful for finding how many times any number is placed in any array. Suppose we have an array with elements as follows: $a = array (54,85,92,54,16,92,48);Output will be: 54 occurs 2 times 85 occurs 1 times 92 occurs 2 times 16 occurs 1 times 48 occurs 1 

PHP Program to Separate Zeros from the given Array elements

By Shyam Dubey on 15 Nov 22 | Filed under: PHP
Hello guys, this program is used to find all the zeros in any given array and shift those zeros in the last for example. Given array: 1 8 5 0 4 0 5 1 0 0 4 Output: 1 8 5 4 5 1 4 0 0 0 0Program:://To separate zeros from the given array elements<html>     <head>&nb

How to convert decimal numbers to binary in PHP

By Shyam Dubey on 15 Nov 22 | Filed under: PHP
This program is written is PHP and HTML to show how to convert decimal number to binary number. Note- there is a inbuilt function in PHP which is used for converting decimal numbers to binary. decbin() function is used for this purpose. Program::// To convert Decimal number into Binary num

Rules for naming variable in PHP

By Pritvik on 31 Oct 22 | Filed under: PHP
A variable starts with the $ sign, followed by the name of the variableA variable name must start with a letter or the underscore characterA variable name cannot start with a numberA variable name can only contain alpha-numeric characters and underscores (A-z, 0-9, and _ )Variable names are case-sen