PHP数组,显示1.apple 2.banana等水果

Ada*_*han 2 php arrays

我有一些数组:

array
  0 => string 'Apple' 
  1 => string 'banana'
  2 => string 'Nanas' 
  3 => string 'Grape'
Run Code Online (Sandbox Code Playgroud)

什么是最好的展示方式

1. Apple
2. banana
3. Nanas
4. Grape 

有任何想法吗?

kar*_*m79 5

如果您输出的输出是HTML,那么有序列表是有意义的:

<ol>
<?php foreach($fruits as $fruit) { ?>
    <li><?php echo $fruit; ?></li>
<?php } ?>
</ol>
Run Code Online (Sandbox Code Playgroud)