"Orange","Banana","Grape","Apple","Flower"); //////////////////////////////////////////////// echo "
//搜尋字串,用計數器的while迴圈,印出陣列:
"; $txt="Apple2"; $i=1; while($i<=count($fruit)){ if($fruit[$i]==$txt){ echo "找到 $txt"; break; } if($i==4){ echo "沒有找到 $txt"; } $i++; } ?>