Ngôn ngữ PHP - Hiển thị giá trị của mảng

Hiển thị giá trị của mảng 

$color = array('white', 'green', 'red'')

Viết script PHP sẽ hiển thị các màu theo cách sau:

Mã nguồn PHP:

<?php
$color = array('white', 'green', 'red');
foreach ($color as $c)
{
echo "$c, ";
}
sort($color);
echo "<ul>";
foreach ($color as $y)
{
echo "<li>$y</li>";
}
echo "</ul>";
?>

Xem ví dụ

Lưu đồ thuật toán:

Flowchart: Display array values in a list