Skip to content

Numerology Calculator in PHP

Reading Time: < 1 minute

PHP is one of the most wanted dynamic languages of all time. Here we tried to build a Numerology Calculator with PHP.

Numerology Calculator in PHP Coding

This Numerology Calculator script is based on PHP Programming Language with the use of Simple Array and Function. It has compatibility with both Chaldean and Pythagorean methods which are widely used.

numerology calculator
Numerology Calculator in PHP
//MAIN FUNCTION
$str="YOUR NAME";
$method="CHALDEAN"; //whether CHALDEAN or PYTHOGOREAN
function numerology($str, $method){


$i=$tot=$net=$res=0;
$nval=[];

if($method=='CHALDEAN'){
  $nval = array('a'=>1, 'b'=>2, 'c'=>3, 'd'=>4, 'e'=>5, 'f'=>8, 'g'=>3, 'h'=>5, 'i'=>1, 'j'=>1, 'k'=>2, 'l'=>3, 'm'=>4, 'n'=>5, 'o'=>7, 'p'=>8, 'q'=>1, 'r'=>2, 's'=>3, 't'=>4, 'u'=>6, 'v'=>6, 'w'=>6, 'x'=>5, 'y'=>1, 'z'=>7);
}
else{
  $nval = array('a'=>1, 'b'=>2, 'c'=>3, 'd'=>4, 'e'=>5, 'f'=>6, 'g'=>7, 'h'=>8, 'i'=>9, 'j'=>1, 'k'=>2, 'l'=>3, 'm'=>4, 'n'=>5, 'o'=>6, 'p'=>7, 'q'=>8, 'r'=>9, 's'=>1, 't'=>2, 'u'=>3, 'v'=>4, 'w'=>5, 'x'=>6, 'y'=>7, 'z'=>8);
}


        //calc word by word
        for($i=0;$i<strlen($str);$i++){
        $tot=$tot+$nval[$str[$i]];
        }
       
        $res=digitval($tot);
        $_GET['result']='<fieldset>
        <legend>'.$method.'</legend>
        <h2>'.strtoupper($_POST['user']).'</h2><h1>'.$res.'</h1>
        </fieldset>';
}


function digitval($number) {
  $res=$rem=$sum=0; 

   while($number > 0){
  		$rem = $number % 10;
  		$number = $number / 10;
  		$sum = $sum + $rem;
    }
    
    $res=$sum;
    if(strlen($sum)>=2){
    $res=digitval($sum);
    }

   return $res;
}
See also  PHP OOPS Tutorial

Share your thoughts

  1. dear can you add some extra feature in your code. like

    1. name
    2. father name
    3. mother name
    4. date of birth
    5. a to z value manually changing option
    6. show result and save to data base
    pleas dear help me on this matter. no mire now bye & TC

    Thanks and regards,
    Sharfuz Zaman
    +8801670182588

  2. Pingback: Family Tree PHP Script - Genealogy Tree Coding in PHP

Leave a Reply