網上的一段代碼哪裡錯了?

來源:互聯網
上載者:User
imgPath = $path;  }/** * 顏色分離轉換... * * @param unknown_type $path * @return unknown */  public function getHec()    {           $size = getimagesize($this->imgPath);        $res = imagecreatefrompng($this->imgPath);                for($i=0; $i < $size[1]; ++$i)        {               for($j=0; $j < $size[0]; ++$j)            {                $rgb = imagecolorat($res,$j,$i);                $rgbarray = imagecolorsforindex($res, $rgb);                               if($rgbarray['red'] < 125 || $rgbarray['green']<125                || $rgbarray['blue'] < 125)                {                    $data[$i][$j]=1;                }else{                    $data[$i][$j]=0;                }            }        }        $this->imgSize = $size;        $this->hecData = $data;    }/** * 顏色分離後的資料橫向整理... * * @return unknown */public function magHorData(){        $data = $this->hecData;    $size = $this->imgSize;        $z = 0;    for($i=0; $i<$size[1]; ++$i)       {         if(in_array('1',$data[$i])){            $z++;            for($j=0; $j<$size[0]; ++$j)            {                   if($data[$i][$j] == '1'){                                       $newdata[$z][$j] = 1;                }else{                   $newdata[$z][$j] = 0;                 }            }                  }         }    return $this->horData = $newdata;} /** * 整理縱向資料... * * @return unknown */public function magVerData($newdata){    for ($i=0;$i<132;++$i){        for($j=1;$j<13;++$j){            $ndata[$i][$j] = $newdata[$j][$i];        }    }      $sum = count($ndata);    $c = 0;    for ($a=0;$a<$sum;$a++){        $value = $ndata[$a];        if(in_array(1,$value)){                          $ndatas[$c] = $value;              $c++;        }elseif(is_array($ndatas)){          $b = $c-1;          if(in_array(1,$ndatas[$b])){              $ndatas[$c] = $value;              $c++;          }        }             }     return $this->verData = $ndatas; }/** * 顯示電話號碼... * * @return unknown */public function showPhone($ndatas){    $phone = null;    $d = 0;    foreach ($ndatas as $key => $val){        if(in_array(1,$val)){            foreach ($val as $k => $v){               $ndArr[$d].=$v;            }        }                if(!in_array(1,$val)){            $d++;        }    }   foreach ($ndArr as $key01 =>$val01){        $phone .= $this->initData($val01);   }      return $phone;}/** * 分離顯示... * * @param unknown_type $dataArr */function drawWH($dataArr){    if(is_array($dataArr)){        foreach ($dataArr as $key => $val){            foreach ($val as $k => $v){                if($v == 0){                    $c .= "".$v."";                }else{                  $c .= $v;                }            }            $c .= "
"; } } echo $c;} /** * 初始資料... * * @param unknown_type $numStr * @return unknown */ public function initData($numStr){ $result = null; $data = array( 0=>'000011111000001111111110011000000011110000000001110000000001110000000001110000000001011000000011011100000111000111111100000001110000', 1=>'011000000000011000000000111111111111111111111111', 2=>'001000000011011000000111110000001101110000011001110000011001110000110001111001100001011111100001000110000001', 3=>'001000000010011000000011110000000001110000000001110000110001110000110001011001110011011111011111000110001100', 4=>'000000001100000000111100000001111100000011101100000111001100001100001100011000001100111111111111111111111111000000001100000000000100', 5=>'111111000001111111000001110001000001110001000001110001100001110001100001110000110011110000111111000000001100', 6=>'000011111000001111111110011000110011110001100001110001100001110001100001110001100001010001110011010000111111000000001100', 7=>'110000000000110000000111110000111111110001110000110111000000111100000000111000000000111000000000', 8=>'000100011110011111111111110011100001110001100001110001100001110001100001110011100001011111111111000100011110', 9=>'001111000000011111100001110000110001110000110001110000110001110000110001011000100001011111100111000111111110000001110000', ); foreach ($data as $key => $val){ similar_text($numStr,$val,$pre); if($pre>95){//相似性95%以上 $result = $key; break; } } return $result; }} $imgPath = "http://bj.ganji.com/tel/5463013757650d6c5e31093e563c51315b6c5c6c5237.png";$gjPhone = new gjPhone($imgPath);//進行顏色分離$gjPhone->getHec();//畫出橫向資料$horData = $gjPhone->magHorData();echo "===============橫向資料==============


";$gjPhone->drawWH($horData);//畫出縱向資料$verData = $gjPhone->magVerData($horData);echo "


===============縱向資料==============


";$gjPhone->drawWH($verData); //輸出電話$phone = $gjPhone->showPhone($verData);echo "


===============電話==============


".$phone;?>



這是一段完整的代碼,為什麼最後不顯示電話號碼呢,橫向和縱向都顯示了
//輸出電話
$phone = $gjPhone->showPhone($verData);
echo "


===============電話==============


".$phone;

這段不顯示


回複討論(解決方案)


這是電話號碼嗎?

http://www.ganji.com/tel_img/?c=kd1LqjAmJoJICgLz3V2gnIbW.eoBw__PtQyX
用這個也不顯示
多幾個橫杠也不行?

要純數字????

看起來蠻NB的,圖片識別,不懂~~

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.