Search code examples
phptextareaecho

Adding Bullets to Preset Textarea Output - PHP


I am trying to add bullets to my defined texture output. I simply created a textarea in php with some preset text. How can I preface each piece of preset text with a bullet. I want the text in my textarea to look like this:

  • Name:
  • Address:
  • DOB:
  • Favorite Drink:

Here is my PHP code:

<?php
  echo "<textarea name=''  id='' style='width: 565px;' rows='8' cols='60'>";
    echo "Name:";
    echo "Address:";
    echo "DOB:";
    echo "Favorite Drink:";
  echo "</textarea>";
?>

Thanks so much for your help!


Solution

  • If you must use a textarea, you can add the 'bullet' HTML entity in the string...

    <?php
      echo "<textarea name=''  id='' style='width: 565px;' rows='8' cols='60'>";
        echo "&#8226; Name:";
        echo "&#8226; Address:";
        echo "&#8226; DOB:";
        echo "&#8226; Favorite Drink:";
      echo "</textarea>";
    ?>
    

    Otherwise, you can go with an unordered list as @Tim Hunter suggested:

    <?php
      echo "<ul>";
        echo "<li>Name:</li>";
        echo "<li>Address:</li>";
        echo "<li>DOB:</li>";
        echo "<li>Favorite Drink:</li>";
      echo "</ul>";
    ?>