Base Class

First Step Download : Swetest64.exe | Swetest32.exe
Download Link :: https://www.astro.com/ftp/swisseph/programs/
Example
$datetime="2000-11-02 22:55:00";
$lat=28.36;
$lon=77.12;
$sfilename="c:/xampp/htdocs/swete64/swetest64.exe"; // full pathname
$kp=true;
$cc= cc($datetime, $lat, $lon,$sfilename,$kp=false);
echo "<pre>";
echo print_r($cc[0],true);
echo print_r($cc[1],true);
echo "</pre>";

Array
(
    [0] => stdClass Object
        (
            [t] => लग्न
            [l] => 90.7958476
            [r] => 
            [s] => 0
            [h] => 1
            [x] => Lg
            [o] => 0° 47'
        )

    [1] => stdClass Object
        (
            [t] => सूर्य
            [l] => 196.8133905
            [r] => 
            [s] => 1.0014986
            [h] => 4
            [x] => Su
            [o] => 16° 48'
        )

    [2] => stdClass Object
        (
            [t] => चन्द्र
            [l] => 269.5136133
            [r] => 
            [s] => 11.7973300
            [h] => 6
            [x] => Mo
            [o] => 29° 30'
        )

    [3] => stdClass Object
        (
            [t] => बुध
            [l] => 188.9327424
            [r] => R
            [s] => -0.9866483
            [h] => 4
            [x] => Me
            [o] => 8° 55'
        )

    [4] => stdClass Object
        (
            [t] => शुक्र
            [l] => 233.7291575
            [r] => 
            [s] => 1.2075825
            [h] => 5
            [x] => Ve
            [o] => 23° 43'
        )

    [5] => stdClass Object
        (
            [t] => मंगल
            [l] => 155.3845948
            [r] => 
            [s] => 0.6169862
            [h] => 3
            [x] => Ma
            [o] => 5° 23'
        )

    [6] => stdClass Object
        (
            [t] => बृहस्पति
            [l] => 45.5777930
            [r] => R
            [s] => -0.1051196
            [h] => 11
            [x] => Ju
            [o] => 15° 34'
        )

    [7] => stdClass Object
        (
            [t] => शनि
            [l] => 35.0584369
            [r] => R
            [s] => -0.0751583
            [h] => 11
            [x] => Sa
            [o] => 5° 3'
        )

    [8] => stdClass Object
        (
            [t] => राहु
            [l] => 85.0574505
            [r] => 
            [s] => 0.0056310
            [h] => 12
            [x] => Ra
            [o] => 25° 3'
        )

    [9] => stdClass Object
        (
            [t] => केतु
            [l] => 265.0574505
            [r] => 
            [s] => 0.0056310
            [h] => 6
            [x] => Ke
            [o] => 25° 3'
        )

)
//House / Bhav--------------------
Array
(
    [1] => 90.7958476
    [2] => 113.9298123
    [3] => 140.5001544
    [4] => 171.8555908
    [5] => 206.3884653
    [6] => 240.1273681
    [7] => 270.7958476
    [8] => 293.9298123
    [9] => 320.5001544
    [10] => 351.8555908
    [11] => 26.3884653
    [12] => 60.1273681
    [13] => 90.7958476
)
Php script
<?php 
function cc($datetime$lat$lon,$sfilename){
$reg[2]=["/UT:\s+([0-9.]+)\s+delta t: ([0-9.]+)/","ut","delta",2];
$reg[3]=["/TT:\s+([0-9.]+)\s+ayanamsa =\s([0-9.°' ]+)/","tt","ayan",1];
$reg[7]=["/Sun\s+([0-9.]+)\s+([0-9.]+)/","Su","Su_speed",1];
$reg[8]=["/Moon\s+([0-9.]+)\s+([0-9.]+)/","Mo","Mo_speed",1];
$reg[9]=["/Mercury\s+([0-9.]+)\s+([\-0-9.]+)/","Me","Me_speed",1];
$reg[10]=["/Venus\s+([0-9.]+)\s+([\-0-9.]+)/","Ve","Ve_speed",1];
$reg[11]=["/Mars\s+([0-9.]+)\s+([\-0-9.]+)/","Ma","Ma_speed",1];
$reg[12]=["/Jupiter\s+([0-9.]+)\s+([\-0-9.]+)/","Ju","Ju_speed",1];
$reg[13]=["/Saturn\s+([0-9.]+)\s+([\-0-9.]+)/","Sa","Sa_speed",1];
$reg[14]=["/Uranus\s+([0-9.]+)\s+([\-0-9.]+)/","Ur","Ur_speed",1];
$reg[15]=["/Neptune\s+([0-9.]+)\s+([\-0-9.]+)/","Ne","Ne_speed",1];
$reg[16]=["/Pluto\s+([0-9.]+)\s+([\-0-9.]+)/","pl","Pl_speed",1];
$reg[17]=["/mean Node\s+([0-9.]+)/","RaM","RaM_speed",1];
$reg[18]=["/true Node\s+([0-9.]+)\s+([\-0-9.]+)/","RaT","RaT_speed",1];
$reg[20]=["/house  1\s+([0-9.]+)/","h1","h1",1];
$reg[21]=["/house  2\s+([0-9.]+)/","h2","h2",1];
$reg[22]=["/house  3\s+([0-9.]+)/","h3","h3",1];
$reg[23]=["/house  4\s+([0-9.]+)/","h4","h4",1];
$reg[24]=["/house  5\s+([0-9.]+)/","h5","h5",1];
$reg[25]=["/house  6\s+([0-9.]+)/","h6","h6",1];
$reg[26]=["/house  7\s+([0-9.]+)/","h7","h7",1];
$reg[27]=["/house  8\s+([0-9.]+)/","h8","h8",1];
$reg[28]=["/house  9\s+([0-9.]+)/","h9","h9",1];
$reg[29]=["/house 10\s+([0-9.]+)/","h10","h10",1];
$reg[30]=["/house 11\s+([0-9.]+)/","h11","h11",1];
$reg[31]=["/house 12\s+([0-9.]+)/","h12","h12",1];
$reg[32]=["/Ascendant\s+([0-9.]+)/","as","ac",1];
$reg[33]=["/MC\s+([0-9.]+)/","mc","mc",1];

$output="";
$out="";
$outer="";
$out2="";


if(
preg_match('/([+|-])([0-9]{2}):([0-9]{2})/',"+05:30",$out)){
    
$pm=isset($out[1])? $out[1] : '+';
$hour=isset($out[2])? (int)$out[2] : 5;
$min=isset($out[3])? (int)$out[3] : 30;
}
else{
$pm='+';
$hour=5;
$min=30;
}


$dd=new DateTime($datetime);
$dd2=new DateTime($datetime);
if(
$pm == '+')
    
$dd2->sub(new DateInterval('PT'.$hour.'H'.$min.'M'));
else
    
$dd2->add(new DateInterval('PT'.$hour.'H'.$min.'M'));
if(
$kp)
exec ($sfilename ."  -house".$lon.",".$lat.",P -ut".$dd2->format("G").".".(int)$dd2->format("i").".".(int)$dd2->format("s")." -fPls -sid5  -b".$dd->format("j").".".$dd->format("n").".".$dd->format("Y")."   ",$output);
    else
exec ($sfilename."  -house".$lon.",".$lat.",W -ut".$dd2->format("G").".".(int)$dd2->format("i").".".(int)$dd2->format("s")." -fPls -sid1  -b".$dd->format("j").".".$dd->format("n").".".$dd->format("Y")."   ",$output);

$outer=[];
foreach(
$output as $k=>$v){
if(isset(
$reg[$k][0])){
preg_match($reg[$k][0],$v,$out);
$outer[$reg[$k][1]]=$out[1];
if(isset(
$out[2]))
$outer[$reg[$k][2]]=$out[2];
}
}
$outer['Ke']=fmod($outer['RaM']+180,360);


$pla=['as','Su','Mo','Me','Ve','Ma','Ju','Sa'];
$pla_hindi=['लग्न','सूर्य','चन्द्र','बुध','शुक्र','मंगल','बृहस्पति','शनि','राहु','केतु'];
$std=['t','l','r','s','h','x','o'];
$chart=[];
foreach(
$pla as $k=>$v){
    
if(isset(
$outer[$v])){
if(
$v == 'as')
$outer['as_speed']=0;
$chart[$k]=new StdClass;
$chart[$k]->{$std[0]}=$pla_hindi[$k];
$chart[$k]->{$std[1]}=$outer[$v];
if(isset(
$outer[$v.'_speed']) && $outer[$v.'_speed'] < 0)
$chart[$k]->{$std[2]}='R';
else
$chart[$k]->{$std[2]}='';

if(isset(
$outer[$v.'_speed']))
$chart[$k]->{$std[3]}=$outer[$v.'_speed'];

for(
$i=1;$i<13;$i++){
if(
bDeg($outer['h'. ($i)],($i==12) ? $outer['h1'] : $outer['h'. ($i 1)],$outer[$v]))
$chart[$k]->{$std[4]}=$i;
}
$chart[$k]->{$std[5]}=($pla[$k]=='as') ? 'Lg':$pla[$k];
$chart[$k]->{$std[6]}=Dmm($outer[$v]);
}
}

for(
$i=1;$i<13;$i++){
$house[$i]=$outer['h'. ($i)];
}
$house['13']=$outer['h1'];

$k=8;
$chart[$k]=new StdClass;
$chart[$k]->{$std[0]}=$pla_hindi[8];
$chart[$k]->{$std[1]}=$outer['RaM'];

if(isset(
$outer['RaT_speed']) && $outer['RaT_speed'] < 0)
$chart[$k]->{$std[2]}='R';
else
$chart[$k]->{$std[2]}='';

if(isset(
$outer['RaT_speed']))
$chart[$k]->{$std[3]}=$outer['RaT_speed'];

for(
$i=1;$i<13;$i++){
if(
bDeg($outer['h'. ($i)],($i==12) ? $outer['h1'] : $outer['h'. ($i 1)],$outer['RaM']))
$chart[$k]->{$std[4]}=$i;
}
$chart[$k]->{$std[5]}='Ra';
$chart[$k]->{$std[6]}=Dmm($outer['RaM']);


$k=9;
$chart[$k]=new StdClass;
$chart[$k]->{$std[0]}=$pla_hindi[9];
$chart[$k]->{$std[1]}=fmod($outer['RaM']+180,360);


if(isset(
$outer['RaT_speed']) && $outer['RaT_speed'] < 0)
$chart[$k]->{$std[2]}='R';
else
$chart[$k]->{$std[2]}='';

if(isset(
$outer['RaT_speed']))
$chart[$k]->{$std[3]}=$outer['RaT_speed'];

for(
$i=1;$i<13;$i++){
if(
bDeg($outer['h'. ($i)],($i==12) ? $outer['h1'] : $outer['h'. ($i 1)],fmod($outer['RaM']+180,360)))
$chart[$k]->{$std[4]}=$i;
}
$chart[$k]->{$std[5]}='Ke';
$chart[$k]->{$std[6]}=Dmm(fmod($outer['RaM']+180,360));



return [
$chart,$house];
}


function 
bDeg($start,$end,$deg){
$a=abs(max($start,$end)-min($start,$end));    
if((
max($start,$end) > 300)    && (min($start,$end) < 40))
{
if(
$deg min($start,$end) || $deg >= max($start,$end))
return 
true;    
}    
else{
if(
$deg>=$start && $deg<$end)    
    return 
true;
}
}


function 
Dmm($dec)
{
     
$vars explode(".",$dec);
    if(
$dec == '' || count($vars) < 1)
    return array(
"deg"=>'',"min"=>'',"sec"=>'');    
   
    
$deg $vars[0];
    if(isset(
$vars[1]))
    
$tempma "0.".$vars[1];
else
    
$tempma "0.0";
    
$tempma $tempma 3600;
    
$min floor($tempma 60);
    
$sec floor($tempma - ($min*60));
    
$deg fmod($deg,30);
    return 
"$deg&deg; $min'";
}   
?>