Home > php教程 > PHP源码 > php 开奖结果换算

php 开奖结果换算

PHP中文网
Release: 2016-05-26 08:18:17
Original
1289 people have browsed it

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(&#39;,&#39;,$shuju[&#39;k&#39;]); //print_r($haoma);

    $a= "第".$haoma[&#39;0&#39;]."期开奖结果\n";
    if ( is_numeric($haoma[&#39;7&#39;])) //判断是否已经开完
        {
    for($i=1;$i<=7;$i++)
    {
    $zhuan=$haoma[$i].liuhe($haoma[$i]).&#39;/&#39;.bolu($haoma[$i])." "; //输出格式
    if ($i==&#39;1&#39;){ $b= &#39;[face26.gif]&#39;.$zhuan;} 
    if ($i==&#39;2&#39;){ $b.= &#39;[face25.gif]&#39;.$zhuan;} 
    if ($i==&#39;3&#39;){ $b.= &#39;[face26.gif]&#39;.$zhuan;} 
    if ($i==&#39;4&#39;){ $b.= &#39;[face26.gif]&#39;.$zhuan;} 
    if ($i==&#39;5&#39;){ $b.= &#39;[face26.gif]&#39;.$zhuan;} 
    if ($i==&#39;6&#39;){ $b.= &#39;[face26.gif]&#39;.$zhuan;} 
    if ($i==&#39;7&#39;){ $b.= &#39;特别号:[face2.gif]&#39;.$zhuan;} 
    }
        }
        else 
        {
            $b= &#39;正在开奖,请等待。。。&#39;;
        }
    $c= "\n第".$haoma[&#39;8&#39;]."期开奖时间".$haoma[&#39;9&#39;]."/".$haoma[&#39;10&#39;]."星期".$haoma[&#39;11&#39;];
    
    echo $a.$b.$c; //整理连接结果 


    //抓取远程网页
        function get($url,$array=&#39;0&#39;)
    { 
    if ($array==&#39;0&#39;) //浏览器信息为空
    {$array= array(
    &#39;User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.152 Safari/537.36&#39;,
    "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(&#39;Accept-Encoding: gzip&#39;);
    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= &#39;红波&#39;;
        }
    elseif ( in_array($haoma,$lan)) {
        $a= &#39;蓝波&#39;;
        }
    elseif ( in_array($haoma,$lv)) {
        $a= &#39;绿波&#39;;
        }
    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[&#39;1&#39;];
        }
    elseif ( in_array($haoma,$sx2)){
        $a= $sx[&#39;2&#39;];
        }
    elseif ( in_array($haoma,$sx3)){
        $a= $sx[&#39;3&#39;];
        }
    elseif ( in_array($haoma,$sx4)){
        $a= $sx[&#39;4&#39;];
        }
    elseif ( in_array($haoma,$sx5)){
        $a= $sx[&#39;5&#39;];
        }
    elseif ( in_array($haoma,$sx6)){
        $a= $sx[&#39;6&#39;];
        }
    elseif ( in_array($haoma,$sx7)){
        $a= $sx[&#39;7&#39;];
        }
    elseif ( in_array($haoma,$sx8)){
        $a= $sx[&#39;8&#39;];
        }
    elseif ( in_array($haoma,$sx9)){
        $a= $sx[&#39;9&#39;];
        }
    elseif ( in_array($haoma,$sx10)){
        $a= $sx[&#39;10&#39;];
        }
    elseif ( in_array($haoma,$sx11)){
        $a= $sx[&#39;11&#39;];
        }
    elseif ( in_array($haoma,$sx12)){
        $a= $sx[&#39;12&#39;];
        }
        }
        else
        {
            $a=&#39;等&#39;;
        }
    return $a; 
    }
Copy after login

                   


Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template