Home  >  Article  >  Backend Development  >  效果的对比显示

效果的对比显示

WBOY
WBOYOriginal
2016-06-13 13:28:47754browse

求一个效果的对比显示
-----------------------------------------------------
2120844 DJ小罗Remix这该死的温柔DISCO
2120843 lucky_twice-魔法项链第一首-DJ-舞曲-慢摇
2120842 Beautiful_Girls_(DJ→梦←Extended_Remix)
2120841 DjRuico_FunkyHouse_Remix
----------------------------------------------------
OKNDR1 DjRuico_FunkyHouse_Remix
DGERR2 lucky_twice-魔法项链第一首-DJ-舞曲-慢摇
EGDSF3 DJ小罗Remix这该死的温柔DISCO
EEEED4 Beautiful_Girls_(DJ→梦←Extended_Remix)
--------------------------------------------------

要实现的效果为:
DJ小罗Remix这该死的温柔DISCO [a]2120844[/a] [bb]EGDSF3[/bb]  
lucky_twice-魔法项链第一首-DJ-舞曲-慢摇 [a]2120843[/a][bb]DGERR2[/bb]
Beautiful_Girls_(DJ→梦←Extended_Remix) [a]2120842[/a][bb]EEEED4[/bb]
DjRuico_FunkyHouse_Remix [a]2120841[/a][bb]OKNDR1[/bb]

其实就是把,A和B记录对比,拿名称做一个唯一的对比,

我想到思路可不知道用什么代码做好。JS 还是ASP 还是PHP

------解决方案--------------------

PHP code
$a = array(
  array('2120844', 'DJ小罗Remix这该死的温柔DISCO'),
  array('2120843', 'lucky_twice-魔法项链第一首-DJ-舞曲-慢摇'),
  array('2120842', 'Beautiful_Girls_(DJ→梦←Extended_Remix)'),
  array('2120841', 'DjRuico_FunkyHouse_Remix'),
);
$b = array(
  array('OKNDR1', 'DjRuico_FunkyHouse_Remix'),
  array('DGERR2', 'lucky_twice-魔法项链第一首-DJ-舞曲-慢摇'),
  array('EGDSF3', 'DJ小罗Remix这该死的温柔DISCO'),
  array('EEEED4', 'Beautiful_Girls_(DJ→梦←Extended_Remix)'),
);
$r = array();

foreach($a as $v) $r[$v[1]][] = $v[0];
foreach($b as $v) $r[$v[1]][] = $v[0];
foreach($r as $k=>$v)
  echo "$k [a]$v[0][/a] [bb]$v[1][/bb]\n";
<br><font color="#e78608">------解决方案--------------------</font><br>
HTML code



<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>test</title>
<style>
td{
    padding:20px;    
}
</style>



<script> function $(id){ return document.getElementById(id); } function text3(){ var text1=$('text1').value; var textArray1=text1.split('\n'); var text2=$('text2').value; var textArray2=text2.split('\n'); var colArray1,colArray2; var resultStr=''; for(var i1 in textArray1){ colArray1=textArray1[i1].split(' '); for(var i2 in textArray2){ colArray2=textArray2[i2].split(' '); if(colArray1[1]==colArray2[1]){ resultStr+=colArray1[1]+' [a]'+colArray1[0]+'[/a] [bb]'+colArray2[0]+'[/bb]\n'; } } } $('text3').value=resultStr; } </script>
Statement:
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