找出陣列中最大值與最小值
宣告一個陣列(5,8,2,3,7,6,9,1,4,8,3,0),然後在陣列中搜尋最大值與最小值,並將其鍵顯示在網頁上
輸出結果:
Array ( [0] => 5 [1] => 8 [2] => 2 [3] => 3 [4] => 7 [5] => 5 [6] => 9 [7] => 1 [8] => 4 [9] => 8 [10] => 3 [11] => 0 )
最大值是:鍵:[6] => 9
最小值是:鍵:[11] => 0
輸出結果:
Array ( [0] => 5 [1] => 8 [2] => 2 [3] => 3 [4] => 7 [5] => 5 [6] => 9 [7] => 1 [8] => 4 [9] => 8 [10] => 3 [11] => 0 )
最大值是:鍵:[6] => 9
最小值是:鍵:[11] => 0
留言
張貼留言