Changing contents of textarea

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Geoff Berrow

    Changing contents of textarea

    I have a textarea on a form whose value is stored in a database. I want to
    display the contents as an unordered list. At the moment I am using * to
    start the line and ; to end the line in the textarea and then replacing
    these characters like so:

    <ul>
    <?php
    $features=$myro w["features"];
    $search = array("*", ";");
    $replace =array("\t\t<li >", "</li>\n");
    $list=str_repla ce($search,$rep lace,$features) ;
    print "$list";
    ?>
    </ul>

    Is it possible to do this without the extra characters, say by just putting
    the list items on separate lines in the textarea?
    --
    Geoff Berrow
  • Jon Kraft

    #2
    Re: Changing contents of textarea

    Geoff Berrow <$bl$@ckdog.co. uk> wrote:
    [color=blue]
    > I have a textarea on a form whose value is stored in a database. I want
    > to
    > display the contents as an unordered list. At the moment I am using * to
    > start the line and ; to end the line in the textarea and then replacing
    > these characters like so:
    >
    > <ul>
    > <?php
    > $features=$myro w["features"];
    > $search = array("*", ";");
    > $replace =array("\t\t<li >", "</li>\n");
    > $list=str_repla ce($search,$rep lace,$features) ;
    > print "$list";
    > ?>
    > </ul>
    >
    > Is it possible to do this without the extra characters, say by just
    > putting the list items on separate lines in the textarea?[/color]

    Hi Geoff,

    Yes:

    <ul>
    <?php
    $features = $myrow["features"];
    $search = "\n";
    $replace = "</li>\n\t\t<li>";
    $list = str_replace($se arch,$replace,$ features);
    print "<li>".$lis t."</li>";
    ?>
    </ul>

    HTH;
    JOn

    Comment

    Working...