kunjara / jyotish

PHP library for calculations in Vedic astrology
http://jyotish.su
175 stars 118 forks source link

[SOLUTION] How to get Bhav (House) ruler by House number #28

Closed nitinmukesh closed 2 years ago

nitinmukesh commented 2 years ago

Use the following code in index.php.

echo '<pre>'; print_r($Analysis -> getBhavaRulers(['1','2','3','4','5','6','7','8','9','10','11','12'], 'D1')); echo '</pre>';

Please note there is an issue in code and it does not display all house rulers. To fix this \src\Base\Analysis.php

comment the following line $rulers = array_unique($rulers);

public function getBhavaRulers(array $bhavas, $vargaKey = Varga::KEY_D1)
    {
        $vargaKeyUcf = ucfirst($vargaKey);
        $data = $this->getVargaData($vargaKeyUcf);

        $rulers = [];
        foreach ($bhavas as $bhava) {
            $Rashi = Rashi::getInstance($data['bhava'][$bhava]['rashi']);
            $rulers[] = $Rashi->rashiRuler;
        }
        //$rulers = array_unique($rulers);
        return $rulers;
    }

output

Array ( [0] => Sk [1] => Bu [2] => Ch [3] => Sy [4] => Bu [5] => Sk [6] => Ma [7] => Gu [8] => Sa [9] => Sa [10] => Gu [11] => Ma )

NOTE: 0 means 1st house and so on.