php 开奖结果换算
程序员文章站
2022-04-09 10:18:59
...
php 开奖结果换算
PHP代码
<?php $shuju=get("http://zhibo.8800kj.com:8889/js/i1i1i1i1i1l1l1l1l0.js?_=".time()); //$shuju=get("http://m.118kj.com/js/i1i1i1i1i1l1l1l1l0.js?_=".time()); //备用开奖接口 $shuju=json_decode($shuju,true); //print_r($shuju); $haoma=explode(',',$shuju['k']); //print_r($haoma); $a= "第".$haoma['0']."期开奖结果\n"; if ( is_numeric($haoma['7'])) //判断是否已经开完 { for($i=1;$i<=7;$i++) { $zhuan=$haoma[$i].liuhe($haoma[$i]).'/'.bolu($haoma[$i])." "; //输出格式 if ($i=='1'){ $b= '[face26.gif]'.$zhuan;} if ($i=='2'){ $b.= '[face25.gif]'.$zhuan;} if ($i=='3'){ $b.= '[face26.gif]'.$zhuan;} if ($i=='4'){ $b.= '[face26.gif]'.$zhuan;} if ($i=='5'){ $b.= '[face26.gif]'.$zhuan;} if ($i=='6'){ $b.= '[face26.gif]'.$zhuan;} if ($i=='7'){ $b.= '特别号:[face2.gif]'.$zhuan;} } } else { $b= '正在开奖,请等待。。。'; } $c= "\n第".$haoma['8']."期开奖时间".$haoma['9']."/".$haoma['10']."星期".$haoma['11']; echo $a.$b.$c; //整理连接结果 //抓取远程网页 function get($url,$array='0') { if ($array=='0') //浏览器信息为空 {$array= array( 'User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.152 Safari/537.36', "Referer: {$url}", );} $ch = curl_init($url); //初始化 curl_setopt($ch, CURLOPT_HEADER, 0); //不返回header部分 //curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1 ); // 使用自动跳转有些报错 curl_setopt($ch, CURLOPT_HTTPHEADER, $array); //发送模拟信息数组需换行 $post_array= array('Accept-Encoding: gzip'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //返回字符串,而非直接输出源码 curl_setopt($ch, CURLOPT_TIMEOUT,3); //超时的秒数 $curl=curl_exec($ch); curl_close($ch); return $curl; } //六合开奖号码转波路程序 //编写日期 2016-03-04 function bolu($haoma) { $hong=array(1,2,7,8,12,13,18,19,23,24,29,30,34,35,40,45,46); //红 $lan=array(3,4,9,10,14,15,20,25,26,31,36,37,41,42,47,48); //蓝 $lv=array(5,6,11,16,17,21,22,27,28,32,33,38,39,43,44,49); //绿 if ( in_array($haoma,$hong)){ $a= '红波'; } elseif ( in_array($haoma,$lan)) { $a= '蓝波'; } elseif ( in_array($haoma,$lv)) { $a= '绿波'; } return $a; } //开奖号码转生肖程序 //编写日期 2016-03-04 function liuhe($haoma) { if (is_numeric($haoma)) { $sx=array("生肖开始", "猴", "羊", "马", "蛇", "龙", "兔", "虎", "牛", "鼠", "猪", "狗", "鸡"); //换年的时候把最后一个生肖移动最前面去 $sx1 = array(1, 13, 25, 37, 49); $sx2 = array(2, 14, 26, 38); $sx3 = array(3, 15, 27, 39); $sx4 = array(4, 16, 28, 40); $sx5 = array(5, 17, 29, 41); $sx6 = array(6, 18, 30, 42); $sx7 = array(7, 19, 31, 43); $sx8 = array(8, 20, 32, 44); $sx9 = array(9, 21, 33, 45); $sx10 = array(10, 22, 34, 46); $sx11 = array(11, 23, 35, 47); $sx12 = array(12, 24, 36, 48); if ( in_array($haoma,$sx1)){ $a= $sx['1']; } elseif ( in_array($haoma,$sx2)){ $a= $sx['2']; } elseif ( in_array($haoma,$sx3)){ $a= $sx['3']; } elseif ( in_array($haoma,$sx4)){ $a= $sx['4']; } elseif ( in_array($haoma,$sx5)){ $a= $sx['5']; } elseif ( in_array($haoma,$sx6)){ $a= $sx['6']; } elseif ( in_array($haoma,$sx7)){ $a= $sx['7']; } elseif ( in_array($haoma,$sx8)){ $a= $sx['8']; } elseif ( in_array($haoma,$sx9)){ $a= $sx['9']; } elseif ( in_array($haoma,$sx10)){ $a= $sx['10']; } elseif ( in_array($haoma,$sx11)){ $a= $sx['11']; } elseif ( in_array($haoma,$sx12)){ $a= $sx['12']; } } else { $a='等'; } return $a; }