Learn How to create a Numerology Calculator in PHP!

Before going to the programming Language. You have to take a look at the below site for knowing numerology values.

Chaldean Numerology Explanation

The script I’m going to write here is based on Chaldean Numerology.

First create an Array of values based on the Numerology Equivalent to the Alphabets.


$ar = 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);

So each Alphabets now holds the determined value based on Chaldean Numerology.

Now create an HTML Form and get the text entered by POST method.


//get the value entered by post method
$str = $_POST['str'];
//make it upper case. to avoid messing with small letters.
$str = strtoupper($str);
//find the length of the string entered
$len = strlen($str);

//set a temp value to calculate
$numero = 0;

//now loop through the string one by one and add the values
for($i=0; $i<$len; $i++)
{
$alpha  = $str[$i];
$numero = $ar[$alpha] + $numero;
}

For loops is used to loop through all the equivalent value for the particular Alphabet and to add them respectively.

 

For your convenience i have give the whole code here.


<?php
error_reporting(0);

if($_POST)

{
// create an array based on chaldean numerology

$ar = 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);

//get the value entered by post method
$str = $_POST['str'];
//make it upper case. to avoid messing with small letters.
$str = strtoupper($str);
//find the length of the string entered
$len = strlen($str);

//set a temp value to calculate
$numero = 0;

//now loop through the string one by one and add the values
for($i=0; $i<$len; $i++)
{
$alpha  = $str[$i];
$numero = $ar[$alpha] + $numero;
}
//print the result
echo "NUMEROLOGY TOTAL IS: ". $numero;
}

?>

<html>
<body>
<form action="" method="post">
<input type="text" name="str"  value="" />
<input type="submit" value="calculate" />
</form>

You can also see the demo in here

Demo

 

13 Comments

Add a Comment

Your email address will not be published. Required fields are marked *