用PHP删除表上的空行

时间:2019-01-11 10:45:34

标签: php

我有桌子:

get_offsets()

我需要:带有产品的空行(产品名称为空)删除该行并将服务移至上一个产品行,并从上一个产品中删除当前服务。示例:

在此表中,我们有GB-MAC-01s-MacBook-Pro:rrtest muruganandham.kuppan$ react-native run-ios Found Xcode project rrtest.xcodeproj Building using "xcodebuild -project rrtest.xcodeproj -configuration Debug -scheme rrtest -destination id=E7283C81-5F0D-4732-BF8B-19DB3C904DA2 -derivedDataPath build" Ignoring unf_ext-0.0.7.5 because its extensions are not built. Try: gem pristine unf_ext --version 0.0.7.5 ▸ Running script 'Start Packager' ** BUILD FAILED ** Installing build/Build/Products/Debug-iphonesimulator/rrtest.app An error was encountered processing the command (domain=NSPOSIXErrorDomain, code=22): Failed to install the requested application The bundle identifier of the application could not be determined. Ensure that the application's Info.plist contains a value for CFBundleIdentifier. Print: Entry, ":CFBundleIdentifier", Does Not Exist 。我需要删除<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css" integrity="sha384-GJzZqFGwb1QTTN6wy59ffF1BuGJpLSa9DkKMp0DgiMDm4iYMj70gZWKYbI706tWS" crossorigin="anonymous"> <table class="table-bordered" width="100%"> <tr> <th>Product</th> <th>Service</th> </tr> <tr> <td>Product 1</td> <td>S11</td> </tr> <tr> <td></td> <td>S13</td> </tr> <tr> <td></td> <td>S14</td> </tr> <tr> <td>Product 2</td> <td>S11</td> </tr> <tr> <td></td> <td>S120</td> </tr> </table>并粘贴:product 1S11单行。

我需要此表作为结果:

S13

我知道如何使用javascript:

S14

但是我需要使用php。我该怎么办? 我在php变量 <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css" integrity="sha384-GJzZqFGwb1QTTN6wy59ffF1BuGJpLSa9DkKMp0DgiMDm4iYMj70gZWKYbI706tWS" crossorigin="anonymous"> <table class="table-bordered" width="100%"> <tr> <th>Product</th> <th>Service</th> </tr> <tr> <td>Product 1</td> <td>S13, S14</td> </tr> <tr> <td>Product 2</td> <td>S120</td> </tr> </table>上有这个html页面。

1 个答案:

答案 0 :(得分:0)

  

通常您无法使用php删除它,但我会建议您在行为空时使用Continue语句

例如

$html = "<tbody>";

foreach($data as $row){
    if(empty($row['parameter'])){
        continue;
    }else{
        $html .= "<tr> <td></td> </tr>";
    }
}
$html .= "</tbody>";