如何在PHP

时间:2017-05-17 07:52:29

标签: php explode implode

$myvar1 = 'this car is most new and fast';
$myvar2 = explode(' ', $myvar1);  // slice on spaces
$myvar3 = implode( ',', $myvar2); //add comman
echo $myvar3;

output = this,car,is,most,new,and fast

但我需要这个输出=这辆车,是最新的,新的,快速的

我需要配对输出。

谢谢大家。

2 个答案:

答案 0 :(得分:1)

这应该这样做:

ThisWorkbook.Sheets(Array("Sheet1", "Sheet2")).Select

ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
    "C:\tempo.pdf", Quality:= xlQualityStandard, IncludeDocProperties:=True, _
     IgnorePrintAreas:=False, OpenAfterPublish:=True

它使用一个设置为true的布尔值,每次运行时都为false,因此只显示逗号的所有其他单词。

答案 1 :(得分:0)

    print: () => {
      let data = $('form').html();
      let w = window.open();  //opens in a new tab
      w.document.write('<html><head><title>Print Document</title>');
      w.document.write('</head><body>');
      w.document.write(data);
      w.document.write('</body></html>');

      w.document.close(); // necessary for IE >= 10
      w.focus(); // necessary for IE >= 10
      w.print();
      w.close();
      return true;
    },

而不是$myvar1 = 'this car is most new and fast'; preg_match_all('/([A-Za-z0-9\.]+(?: [A-Za-z0-9\.]+)?)/', $myvar1,$myvar2); // splits string on every other space $myvar3 = implode( ',', $myvar2[0]); //add comman echo $myvar3; ,我使用explode())将字符串和preg_match_all(拆分为',' 这是你的输出:

  

这辆车,是最新的,快速的,