网上的一段代码哪里错了?
程序员文章站
2022-05-10 16:13:37
...
imgPath = $path; }/** * 颜色分离转换... * * @param unknown_type $path * @return unknown */ public function getHec() { $size = getimagesize($this->imgPath); $res = imagecreatefrompng($this->imgPath); for($i=0; $i imgSize = $size; $this->hecData = $data; }/** * 颜色分离后的数据横向整理... * * @return unknown */public function magHorData(){ $data = $this->hecData; $size = $this->imgSize; $z = 0; for($i=0; $ihorData = $newdata;} /** * 整理纵向数据... * * @return unknown */public function magVerData($newdata){ for ($i=0;$iverData = $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的,图片识别,不懂~~