"Orange","Banana","Grape","Apple","Flower"); //////////////////////////////////////////////// echo "
//搜尋字串,不用計數器的while迴圈,印出陣列:
"; $txt="Apple"; while(($v=current($fruit)) != NULL){ if($v==$txt){ echo "找到 $txt"; break; } if(key($fruit)==count($fruit)){ echo "沒有找到 $txt"; } next($fruit); } //////////////////////////////////////////////// ?>