Technology Programming

How to Add a Bullet in PHP

    • 1). Open a blank plain text file. Type the line "<?php" (without quote marks) to start the PHP script.

    • 2). Enter this line to create the array that will be added to the unordered list:

      $values = array('apple', 'orange', 'pear', 'plum', 'grapefruit');

    • 3). Type these lines to create the HTML document:

      echo "<html>";
      echo "<body>";
      echo "<h3> My Favorite Fruits</h3>".PHP_EOL;
      echo "<ul>";

    • 4). Create the "While" loop that will print each of the list items to the screen. Each item will have a bullet before the value:

      $num=count($values);
      $i = 0;

      while ($i < $num){

      echo "<li>".$values[$i]."</li>".PHP_EOL;
      $i++;
      }

    • 5). Close the list, the HTML document and the PHP script with this code:

      echo "</ul>";
      echo "</body>";
      echo "</html>";
      ?>

    • 6). Save the file with a ".php" file extension.

Leave a reply