在每行之前打印一个字母,而不使用<ol>或已编译的数组

Witch is the best way to print a letter (beginning from A) before each row of a list without using html ordered list <ol><li></li>...</ol> and without using an array that contain the alphabet?

es:
A. first row
B. second row
C. third row

thanks for your suggestion!

How about this, using ++ on a variable containing a letter...

$letter = 'A';
foreach ($list as $item) {
    echo $letter++, '. ', $item, "
";
}

See the increment operator's manual page for more information on this behaviour. Essentially, calling ++ on a one-character string, where that character is an A-Za-z letter, will make the string into the next letter.

You could use a string and substr it on every iteration:

<?php

$alph = 'abcdefghijklmnopqrstuvwxyz';

$rows = array(); //whatever your rows are that you're printing

$i = 0;
foreach($rows AS $r): ?>

<?php echo substr($alph, $i, 1); ?> x row<br>

<?php $i ++; endforeach; ?>

Depending upon how long your list is, you can get away with this:

$start = 'A';
foreach ($lists as $li) {
   echo "$start. $li
";
   $start++;
}

If you don't even want to specify the start, you can use the ascii codes too.

foreach ($lists as $num => $li) {
   echo chr($num + 65) . ". $li
";
}

Something like this?

<?php
for($i=0; $i<10; $i++) 
{
    echo chr(65+$i) . '. ' . $1;
}
?>
$l = 'a';
foreach($rows as $row) {
    echo strtoupper($l).". {$row}
";
    $l++
}