Home Backend Development PHP Tutorial 有没有人喜欢讨论一上将QQ数字等级输出为图片显示

有没有人喜欢讨论一上将QQ数字等级输出为图片显示

Jun 13, 2016 pm 12:56 PM
gt http img Level nbsp

有没有人喜欢讨论一下将QQ数字等级输出为图片显示

本帖最后由 laiyilong 于 2012-12-23 06:26:55 编辑 学PHP没多久,突然想到怎样来实现这个,只当是锻炼锻炼,假设等级图片地址如下(晕,貌似只有登录QQ网站后才能显示这几个图片)
http://www.myexception.cn/img/2013/01/16/1107071118.png  皇冠
http://www.myexception.cn/img/2013/01/16/1107071119.png  太阳
http://www.myexception.cn/img/2013/01/16/1107071120.png  月亮
http://www.myexception.cn/img/2013/01/16/1107071121.png  星星

我已经写好了一个

$a = base_convert(85,10,4); //85为数字等级<br />
$b = array(1=>'star',2=>'moon',3=>'sun',4=>'crown');<br />
$e = strlen($a);<br />
for($i=0;$i<$e;$i++){<br />
	$c = (int)substr($a,$i,1);<br />
	if($c>0) for($d=0;$d<$c;$d++) echo '<img  src="/static/imghw/default1.png"  data-src="http://id.qq.com/level/img/'.$b[$e-$i].'.png"  class="lazy"  .$b[$e-$i].'.png" / alt=" 有没有人喜欢讨论一上将QQ数字等级输出为图片显示 " >';<br />
}
Copy after login


主要是利用十进制转四进制来实现,不知道哪位还有更好的办法来实现呢?




------解决方案--------------------
if(isset($_GET['img'])) {<br />
  die(file_get_contents("http://id.qq.com/level/img/$_GET[img].png"));<br />
}<br />
$a = base_convert(85,10,4); //85为数字等级<br />
$b = array(1=>'star',2=>'moon',3=>'sun',4=>'crown');<br />
$e = strlen($a);<br />
for($i=0;$i<$e;$i++){<br />
    $c = (int)substr($a,$i,1);<br />
    if($c>0) for($d=0;$d<$c;$d++) echo '<img  src="/static/imghw/default1.png"  data-src="?img='.$b[$e-$i].'"  class="lazy"  .$b[$e-$i].'" / alt=" 有没有人喜欢讨论一上将QQ数字等级输出为图片显示 " >';<br />
}
Copy after login

------解决方案--------------------
<br>
<?php <br />
function qqdj($nowlevel)<br>
{<br>
	/*星星1 月亮4 太阳16 皇冠64 */<br>
	$a = $b = $c = $d = 0; <br>
	$d = floor($nowlevel/64);<br>
		$dj= $nowlevel%64;<br>
	$c = floor($dj/16);<br>
		$dj = $dj%16;<br>
	$b = floor($dj/4);<br>
	$a = $dj%4;<br>
	return array($a,$b,$c,$d);<br>
}<br>
<br>
function qqdjImg($nowlevel)<br>
{<br>
	/*星星1 月亮4 太阳16 皇冠64 */<br>
	$arrDJ = array();<br>
	$arrDJ[] = floor($nowlevel/64);<br>
		$dj= $nowlevel%64;<br>
	$arrDJ[] = floor($dj/16);<br>
		$dj = $dj%16;<br>
	$arrDJ[] = floor($dj/4);<br>
	$arrDJ[] = $dj%4;<br>
	<br>
	$arrImg = array(<br>
	'<img  src="/static/imghw/default1.png" data-src="http://id.qq.com/level/img/crown.png" class="lazy" alt=" 有没有人喜欢讨论一上将QQ数字等级输出为图片显示 " >',<br>
	'<img  src="/static/imghw/default1.png" data-src="http://id.qq.com/level/img/sun.png" class="lazy" alt=" 有没有人喜欢讨论一上将QQ数字等级输出为图片显示 " >',<br>
	'<img  src="/static/imghw/default1.png" data-src="http://id.qq.com/level/img/moon.png" class="lazy" alt=" 有没有人喜欢讨论一上将QQ数字等级输出为图片显示 " >',<br>
	'<img  src="/static/imghw/default1.png" data-src="http://id.qq.com/level/img/star.png" class="lazy" alt=" 有没有人喜欢讨论一上将QQ数字等级输出为图片显示 " >',<br>
	);<br>
	$html = '';<br>
	foreach ($arrDJ as $k =&gt; $v) <br>
	{<br>
		$html .= str_repeat($arrImg[$k],$v);<br>
	}<br>
	<br>
	print_r($arrDJ);<br>
	return  $html;<br>
}<br>
<br>
<br>
<br>
$dj = 37;<br>
$dj = 71;<br>
echo qqdjImg($dj);<br>
<br>
/*<br>
X-Powered-By: PHP/5.2.0<br>
Content-type: text/html<br>
<br>
Array<br>
(<br>
    [0] =&gt; 1<br>
    [1] =&gt; 0<br>
    [2] =&gt; 1<br>
    [3] =&gt; 3<br>
)<br>
<img  src="/static/imghw/default1.png" data-src="http://id.qq.com/level/img/crown.png" class="lazy" alt=" 有没有人喜欢讨论一上将QQ数字等级输出为图片显示 " ><img  src="/static/imghw/default1.png" data-src="http://id.qq.com/level/img/moon.png" class="lazy" alt=" 有没有人喜欢讨论一上将QQ数字等级输出为图片显示 " ><img  src="/static/imghw/default1.png" data-src="http://id.qq.com/level/img/star.png" class="lazy" alt=" 有没有人喜欢讨论一上将QQ数字等级输出为图片显示 " ><img  src="/static/imghw/default1.png" data-src="http://id.qq.com/level/img/star.png" class="lazy" alt=" 有没有人喜欢讨论一上将QQ数字等级输出为图片显示 " ><img  src="/static/imghw/default1.png" data-src="http://id.qq.com/level/img/star.png" class="lazy" alt=" 有没有人喜欢讨论一上将QQ数字等级输出为图片显示 " > <div class="clear">
                 
              
              
        
            </div>
Copy after login
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

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Solution: Your organization requires you to change your PIN Solution: Your organization requires you to change your PIN Oct 04, 2023 pm 05:45 PM

Solution: Your organization requires you to change your PIN

How to adjust window border settings on Windows 11: Change color and size How to adjust window border settings on Windows 11: Change color and size Sep 22, 2023 am 11:37 AM

How to adjust window border settings on Windows 11: Change color and size

What are the differences between Huawei GT3 Pro and GT4? What are the differences between Huawei GT3 Pro and GT4? Dec 29, 2023 pm 02:27 PM

What are the differences between Huawei GT3 Pro and GT4?

Display scaling guide on Windows 11 Display scaling guide on Windows 11 Sep 19, 2023 pm 06:45 PM

Display scaling guide on Windows 11

10 Ways to Adjust Brightness on Windows 11 10 Ways to Adjust Brightness on Windows 11 Dec 18, 2023 pm 02:21 PM

10 Ways to Adjust Brightness on Windows 11

How to turn off private browsing authentication for iPhone in Safari? How to turn off private browsing authentication for iPhone in Safari? Nov 29, 2023 pm 11:21 PM

How to turn off private browsing authentication for iPhone in Safari?

What does http status code 520 mean? What does http status code 520 mean? Oct 13, 2023 pm 03:11 PM

What does http status code 520 mean?

Win10/11 digital activation script MAS version 2.2 re-supports digital activation Win10/11 digital activation script MAS version 2.2 re-supports digital activation Oct 16, 2023 am 08:13 AM

Win10/11 digital activation script MAS version 2.2 re-supports digital activation

See all articles