PHP函数:将数据带到普通视图

PHP函数:将数据带到普通视图,php,wordpress,Php,Wordpress,我有一个WordPress的功能: <?php function wpcf7_modify_this( $WPCF7_ContactForm ) { $comment = "Row_1: " . $_POST['step1'] . ", Row_2: " . $_POST['step2'] . ", Row_3: " . $_POST['step3'] . ", Row_4: " . $_POST['step4'] . ", Row_5: " . $_POST['step51']

我有一个WordPress的功能:

<?php
function wpcf7_modify_this( $WPCF7_ContactForm ) {
    $comment = "Row_1: " . $_POST['step1'] . ", Row_2: " . $_POST['step2'] . ", Row_3: " . $_POST['step3'] . ", Row_4: " . $_POST['step4'] . ", Row_5: " . $_POST['step51'] . $_POST['step52'] . $_POST['step53'] . $_POST['step54'] . $_POST['step55'] . $_POST['step56'] . ", Row_6: " . $_POST['step61'] . ", " . $_POST['step62'] . ", ". $_POST['step63'];
    $roistatData = array(
      'name'    => isset($_POST['text-14'])    ? $_POST['text-14'] : null,
      'phone'   => isset($_POST['tel-854'])   ? $_POST['tel-854'] : null,
      'comment' => $comment,
   );
   file_get_contents("https://cloud.com/api/add?" . http_build_query($roistatData));
}
add_action("wpcf7_before_send_mail", "wpcf7_modify_this");
?>

数据以以下形式提供(一行):

我想这样:)

请帮我把数据恢复正常。 对不起,我的英语:)


感谢您的帮助。

通过添加

标记来尝试此操作

    <?php
function wpcf7_modify_this( $WPCF7_ContactForm ) {
    $comment = "Row_1: " . $_POST['step1'] . ",\n Row_2: " . $_POST['step2'] . ",\n Row_3: " . $_POST['step3'] . ",\n Row_4: " . $_POST['step4'] . ",\n Row_5: " . $_POST['step51'] . $_POST['step52'] . $_POST['step53'] . $_POST['step54'] . $_POST['step55'] . $_POST['step56'] . ",\n Row_6: " . $_POST['step61'] . ", " . $_POST['step62'] . ", ". $_POST['step63'];
    $roistatData = array(
      'name'    => isset($_POST['text-14'])    ? $_POST['text-14'] : null,
      'phone'   => isset($_POST['tel-854'])   ? $_POST['tel-854'] : null,
      'comment' => $comment,
   );
   file_get_contents("https://cloud.com/api/add?" . http_build_query($roistatData));
}
add_action("wpcf7_before_send_mail", "wpcf7_modify_this");
?>

使用

\n

  <?php
    function wpcf7_modify_this( $WPCF7_ContactForm ) {
        $comment = "Row_1: " . $_POST['step1'] . ",<br/> Row_2: " . $_POST['step2'] . ",<br/> Row_3: " . $_POST['step3'] . ",<br/> Row_4: " . $_POST['step4'] . ",<br/> Row_5: " . $_POST['step51'] . $_POST['step52'] . $_POST['step53'] . $_POST['step54'] . $_POST['step55'] . $_POST['step56'] . ",<br/> Row_6: " . $_POST['step61'] . ", " . $_POST['step62'] . ", ". $_POST['step63'];
        $roistatData = array(
          'name'    => isset($_POST['text-14'])    ? $_POST['text-14'] : null,
          'phone'   => isset($_POST['tel-854'])   ? $_POST['tel-854'] : null,
          'comment' => $comment,
       );
       file_get_contents("https://cloud.com/api/add?" . http_build_query($roistatData));
    }
    add_action("wpcf7_before_send_mail", "wpcf7_modify_this");
    ?>


只需添加换行符
\n
?或者如果是HTML,

。谢谢你的提示,但我是PHP新手。@FanisLee检查编辑过的答案,看看这里的示例谢谢你的帮助。