我的格式如下:
Bin(WRIGHT NT) Test Item
Bin1              -
Bin2              -
Bin3              61
Bin4              50
Bin5              30
Bin6              100
Bin7              1
Bin8              118代码如下:<table border="0" align="right" cellpadding="0" cellspacing="1" bgcolor="#B0C5FF" width="600"> 
<tr class="cells" onmouseover="this.className='cells2'" onmouseout="this.className='cells'"><td bgColor=#cedcff width=30%><strong>Bin(WRIGHT NT)</strong></td><td bgColor=#cedcff width=40%><strong>Test Item</strong></td></tr> 
<?php
function foo($s, $t) {
$p = split('\|', $s);
do{
//print_r($p);
$n = array_search(max($p), $p);
//if(@in_array($n, $t)) return $n;
if(@in_array($n, $t) && max($p)!=0) return $n;
unset($p[$n]);
}while($p);
return '-';
}foreach($arr3 as $bin => $binItem)
{
?>
<tr class="cells" onmouseover="this.className='cells2'" onmouseout="this.className='cells'"><td width=50%><?php echo "Bin".$bin;?></td><td width=50%>
<?php 
echo foo($binItem, $bin2test_item[$bin]);
?></td></tr>
<?php
}
?>
</table>能不能把格式变成这个样子?将bin1和bin2的项去除,从bin3开始循环,直到bin8?
Bin(WRIGHT NT) Test Item
Bin3              61
Bin4              50
Bin5              30
Bin6              100
Bin7              1
Bin8              118请教各位如何实现?

解决方案 »

  1.   

    Dut Bin(WRIGHT NT)
    3 Bin 7
    12 Bin 7
    33 Bin 7
    133 Bin 7
    148 Bin 7
    251 Bin 7
    256 Bin 7
    Bin(WRIGHT NT) Test Item
    Bin1 -
    Bin2 -
    Bin3 61
    Bin4 50
    Bin5 30
    Bin6 100
    Bin7 1
    Bin8 118我现在要把这两张表合并,如下图:
    Dut Bin(WRIGHT NT)    Test Item
    3 Bin 7                1
    12 Bin 7                1
    33 Bin 7                1
    133 Bin 7                1
    148 Bin 7                1
    251 Bin 7                1
    256 Bin 7                1只显示对应bin的test item该怎么做?
      

  2.   

    忘了贴代码了-_-!! :table1:
    <table border="0" align="left" cellpadding="0" cellspacing="1" bgcolor="#B0C5FF" width="600">
    <tr class="cells" onmouseover="this.className='cells2'" onmouseout="this.className='cells'"><td bgColor=#cedcff width=30%><strong>Dut</strong></td><td bgColor=#cedcff width=40%><strong>Bin(WRIGHT NT)</strong></td></tr>
    <?php
    for($i=0;$i<count($save);$i++)
    {
    ?>
    <tr class="cells" onmouseover="this.className='cells2'" onmouseout="this.className='cells'"><td width=30%>
    <?php
    echo trim($save[$i]);
    ?>
    <td width=70%>
    <?php
    echo trim("Bin ".$resultsArray[$save[$i]]);
    ?></td>
    <?php
       } 
    ?>
    </tr>
    </table>table2:
    <table border="0" align="right" cellpadding="0" cellspacing="1" bgcolor="#B0C5FF" width="600"> 
    <tr class="cells" onmouseover="this.className='cells2'" onmouseout="this.className='cells'"><td bgColor=#cedcff width=30%><strong>Bin(WRIGHT NT)</strong></td><td bgColor=#cedcff width=40%><strong>Test Item</strong></td></tr> 
    <?php
    function foo($s, $t) {
    $p = split('\|', $s);
    do{
    //print_r($p);
    $n = array_search(max($p), $p);
    //if(@in_array($n, $t)) return $n;
    if(@in_array($n, $t) && max($p)!=0) return $n;
    unset($p[$n]);
    }while($p);
    return '-';
    }foreach($arr3 as $bin => $binItem)
    {
    ?>
    <tr class="cells" onmouseover="this.className='cells2'" onmouseout="this.className='cells'"><td width=50%><?php echo "Bin".$bin;?></td><td width=50%>
    <?php 
    echo foo($binItem, $bin2test_item[$bin]);
    ?></td></tr>
    <?php
    }
    ?>
    </table>
      

  3.   

    改成这样试试看吧
    <table border="0" align="left" cellpadding="0" cellspacing="1" bgcolor="#B0C5FF" width="600">
    <tr class="cells" onmouseover="this.className='cells2'" onmouseout="this.className='cells'"><td bgColor=#cedcff width=30%><strong>Dut</strong></td><td bgColor=#cedcff width=40%><strong>Bin(WRIGHT NT)</strong></td><td bgColor=#cedcff width=30%><strong>Test Item</strong></td></tr>
    <?php
    function foo($s, $t) {
    $p = split('\|', $s);
    do{
    //print_r($p);
    $n = array_search(max($p), $p);
    //if(@in_array($n, $t)) return $n;
    if(@in_array($n, $t) && max($p)!=0) return $n;
    unset($p[$n]);
    }while($p);
    return '-';
    }    for($i=0;$i<count($save);$i++)
        {
    ?>
    <tr class="cells" onmouseover="this.className='cells2'" onmouseout="this.className='cells'">
    <td width=30%>
    <?php
    echo trim($save[$i]);
    ?>
    </td>
    <td width=40%>
    <?php
    echo trim("Bin ".$resultsArray[$save[$i]]);
    ?>
    </td>
    <td width=30%>
    <?php
    foreach($arr3 as $bin => $binItem)
    {
    if ($bin == $resultsArray[$save[$i]] )
    echo foo($binItem, $bin2test_item[$bin]);
    }
    ?>
    </td>
    <?php
       } 
    ?>    
    </tr>    
    </table>
      

  4.   

    1、只是简单的去掉前两个的话  在foreach前加上array_shift( array_shift($arr3) )或unset($arr3[0], $arr3[1])
      

  5.   

    谢谢!
    unset()函数可以使用。