如何在php中使用out\n\t\r进行回显?

如何在php中使用out\n\t\r进行回显?,php,html,mysql,Php,Html,Mysql,在“我的代码”中,选择以下选项: <select name="TutorName"> <?php while ($tutor = mysql_fetch_array($resultTutor, MYSQL_ASSOC)) { ?> <option value="<?php echo $tutor['TutorPrefix'];?> <?

在“我的代码”中,选择以下选项:

<select name="TutorName">
        <?php
        while ($tutor = mysql_fetch_array($resultTutor, MYSQL_ASSOC)) {
        ?>
        <option value="<?php echo $tutor['TutorPrefix'];?> 
                        <?php echo $tutor['TutorFirstName'];?> 
                        <?php echo $tutor['TutorLastName'];?>">
                        <?php echo $tutor['TutorPrefix'];?> 
                        <?php echo $tutor['TutorFirstName'];?> 
                        <?php echo $tutor['TutorLastName'];?> </option>

        <?php
        }
        ?>
        </select>
如何在没有out的情况下将它们合并为一行\r\n\t

我试过这个,但它不起作用

<?php echo $tutor['TutorPrefix']$tutor['TutorFirstName']$tutor['TutorLastName'];?>
注意引用

或者,您可以使用以下方法:

while ($tutor = mysql_fetch_array($resultTutor, MYSQL_ASSOC)) {
    $input = "<option value='$tutor[TutorPrefix] 
                    $tutor[TutorFirstName] 
                    $tutor[TutorLastName]'>
                    $tutor[TutorPrefix] 
                    $tutor[TutorFirstName] 
                    $tutor[TutorLastName]'
              </option>";
    //Do some processing according to the other answers
    echo removeunwantedcharcters($input);
}
试试这个

$output = str_replace(array("\r","\n","\t"), "", $input);
$regex = '/(\s|\\\\[rntv]{1})/';
$output = preg_replace($regex, '', $input);
也试试这个

$output = str_replace(array("\r","\n","\t"), "", $input);
$regex = '/(\s|\\\\[rntv]{1})/';
$output = preg_replace($regex, '', $input);
你可以用

$cleanString = trim($strname, "\t");
从字符串中删除不需要的字符


请参阅无法解决其特定问题的php文档

,因为\r\n\t字符不在其数据集中,而是在其HTML中。除非将HTML代码首先放入字符串变量中,否则它们将…………tryNot。但是,在此上下文中,它直接输出到浏览器。我从未声称代码有错误。除非他将HTML代码放入实际的字符串变量中,否则此解决方案对他没有任何好处。此工作值=>
$cleanString = trim($strname, "\t");