P粉5305192342023-08-17 10:59:14
表單
<?php $CompetitorPartNumbers = $_POST['CompetitorPartNumbers'] ?? 'Test'; ?> <form method="post" action=""> <label for="CompetitorPartNumber">竞争对手零件编号:</label><br> <textarea rows="4" id="CompetitorPartNumber" name="CompetitorPartNumbers" cols="50" name="comment"> <?= $CompetitorPartNumbers ?></textarea><br> <input type='submit' value='立即下载' class="SubmitButton">
目標腳本
<?php $CompetitorPartNumbers = $_POST['CompetitorPartNumbers'] ?? 'Test'; echo "<h1>纯文本输入</h1>"; echo "<pre>".$CompetitorPartNumbers."</pre>"; // 按换行符分割 $CompetitorPartNumbersEx = explode("\n", $CompetitorPartNumbers); // 按回车换行符分割 $CompetitorPartNumbersEx = explode("\n\r", $CompetitorPartNumbers); // 按当前平台的正确换行符分割 $CompetitorPartNumbersEx = explode(PHP_EOL, $CompetitorPartNumbers); ?> <h1><code>explode()</code> 将值按行分割</h1> <pre><?= print_r($CompetitorPartNumbersEx, true) ?></pre> <h2>计算行数</h2> <samp><?='count = '.count($CompetitorPartNumbersEx) ?></samp>#