为什么我得到空白

时间:2017-05-03 12:46:04

标签: php arrays post

我正在迭代$ _POST将每个项目写入文本文件。它工作正常,但尽管使用了'strlen'为了避免空白,我仍然得到一些。谁能告诉我为什么?这是我的代码:

Dim pp As Object
Dim PPPres As Object
Dim PPSlide As Object
Dim Rng As Range

DestinationPPT = "C:\Users\username\Desktop\Data_Display.pptx"
Set pp = CreateObject("PowerPoint.Application")
Set PPPres = pp.Presentations.Open(DestinationPPT)
pp.Visible = True
Set Rng = ActiveSheet.Range("CA1:CJ" & Count + 1)

Rng.Copy

SlideCount = PPPres.Slides.Count
Set PPSlide = PPPres.Slides.Add(SlideCount, 12)
pp.ActivePresentation.Application.CommandBars.ExecuteMso ("PasteSourceFormatting")

PPSlide.Shapes(1).Select
pp.ActiveWindow.Selection.ShapeRange.Align msoAlignTops, True
pp.ActiveWindow.Selection.ShapeRange.Top = 65
pp.ActiveWindow.Selection.ShapeRange.Left = 7.2
pp.ActiveWindow.Selection.ShapeRange.Width = 700

Set PPSlide = Nothing
Set PPPres = Nothing
Set pp = Nothing

1 个答案:

答案 0 :(得分:0)

尝试下面的解决方案代码:

$entries = "";
$filename = "test.txt";
foreach($_POST as $value) {
    if( is_array( $value ) ) {
        foreach( $value as $subvalue ) {
            if (strlen(trim($subvalue)) > 5) {
                $entries .= $subvalue . PHP_EOL;
            }
        }
    }
}
file_put_contents($filename, $entries);