Aleksandrs Posted August 18, 2005 Report Share Posted August 18, 2005 (edited) Radās vajadzība pēc automātiskas horoskopa noteikšanas uzrakstiju kodu, varbūt kādam noder. Varbūt ir iespēja šo kodu optimizet mazāku ? function get_horoskops($birthday){//Y-m-d $date=explode('-', $birthday); $y = $date[0]; $m = $date[1]; $d = $date[2]; $date_who = array( 1 => array('Auns', '21.03', '20.04'), 2 => array('Vērsis', '21.04', '20.05'), 3 => array('Dvīņi', '21.05', '21.06'), 4 => array('Vēzis', '22.06', '22.07'), 5 => array('Lauva', '23.07', '23.08'), 6 => array('Jaunava', '24.08', '23.09'), 7 => array('Svari', '24.09', '23.10'), 8 => array('Skorpions', '24.10', '22.11'), 9 => array('Strēlnieks', '23.11', '21.12'), 10 => array('Mežāzis', '22.12', '20.01'), 11 => array('Ūdensvīrs', '21.01', '20.02'), 12 => array('Zivs', '21.02', '20.03') ); $i = 0; foreach($date_who as $i => $h){ $no = $h[1]; #No kura $lidz = $h[2]; #Liidz kuram $h = $h[0]; #Horoskops $no = explode('.', $no); $dn = $no[0]; $mn = $no[1]; $lidz = explode('.', $lidz); $dl = $lidz[0]; $ml = $lidz[1]; if(($m==$mn && $d>=$dn) || ($m==$ml && $d<=$dl)){ $horoskops = $date_who[$i][0]; } } return $horoskops; } Labots.. Edited August 18, 2005 by Aleksandrs Link to comment Share on other sites More sharing options...
v3rb0 Posted August 18, 2005 Report Share Posted August 18, 2005 (edited) nu isak shita varetu http://paste.php.lv/2347 Edited August 18, 2005 by v3rb0 Link to comment Share on other sites More sharing options...
Recommended Posts