我有文本在,textfield上,那些文本是。http://****
http://****
http://****我想实现一个这样的功能。1,http://****
2,http://****
3,http://****
..,http://****写的代码如下:(请高手看看我错出在哪里)<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head><body>
<form action="z.php" method="post">
  <label>
  <textarea name="textfield" cols="50" rows="10"></textarea>
  </label>
  <input name="submit" type="submit" id="submit" value="转换" />
  <textarea cols="50" rows="10">
<?
$textfield = $_POST["textfield"];
$i = 1 . ',';
$str_textfield = preg_replace('/^/',$i,$textfield);
echo $str_textfield;
?>
  </textarea>
</form>
</body>
</html>

解决方案 »

  1.   


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>无标题文档</title>
    </head><body>
    <form action="" method="post">
      <label>
      <textarea name="textfield" cols="50" rows="10"></textarea>
      </label>
      <input name="submit" type="submit" id="submit" value="转换" />
      <textarea cols="50" rows="10">
    <?php
    $textfield = $_POST["textfield"];
    $i = 1 . ',';
    $str_textfield = preg_replace('/^/',$i,$textfield);
    echo $str_textfield;
    ?>
      </textarea>
    </form>
    </body>
    </html>你php.ini没有配置short tag的话,就用这个:<?php ?>
      

  2.   

    获取 txtearea 的内容按 换行符为间隔,截成 数组循环输出数组就行了