Using foreach to Iterate through an Array
<?php
$prog_language[] = "PHP";
$prog_language[] = "C";
$prog_language[] = "C++";
$prog_language[] = "Java";
$prog_language[] = "Forth";
$prog_language[] = "Perl";
$prog_language[] = "Python";
$prog_language[] = "Ruby";
foreach($prog_language as $language)
{
if(!strcmp($language, "PHP")){
print("<b>" . $language . "</b> <br />");
}else{
print($language . " <br />");
}
}
?>
Related examples in the same category