Hola 
creado una nueva funcion y necesito que la imprima dentro de una tabla pero me la deja fuera.    
Código PHP:
Ver originalecho '<table class="table  table-bordered table-striped datatable"  id="table-2">';
echo    '<thead>';
echo        '<tr class="success" >';
echo            '<th>Contrato</th>';
echo            '<th>Cliente</th>';
echo            '<th>Matricula Tractora</th>';
echo            '<th>DNI PASAPORTE</th>';
echo            '<th>Matricula Remolque</th>';
echo            '<th>Nombre</th>';
echo            '<th>Estado</th>';  
echo        '</tr>';
echo    '</thead>'; 
function muestraEstado($estado)
{
    if($estado === 'Confirmada') {
        echo '<button type="button" class="btn btn-success">
            <i class="entypo-check"></i>
        </button>';
    } else {
        echo $estado;
    }
}
 
 foreach($distribuciones as $distrib) {
 
 echo ' <tbody>
        <tr>
            <td>'.$distrib->Contrato.'</td>
            <td>'.$distrib->Cliente.'</td>
            <td>'.$distrib->Matricula_tractora.'</td>
            <td>'.$distrib->DNI_conductor.'</td>
            <td>'.$distrib->Matricula_remolque.'</td>
            <td>'.$distrib->Nombre_conductor.'</td>
            <td>'.muestraEstado($distrib->Estado).'</td>  <---------------- esto deberia imprimrlo en la tabla
            </tr>';        
 
  }     
}
echo '</table>';
  
ejemplo:
[IMG]
 subir foto[/IMG]  
como podeis comprobar lo hace fuera 
alguien sabe porque?