-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmaximum.php
More file actions
63 lines (40 loc) · 1.08 KB
/
maximum.php
File metadata and controls
63 lines (40 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
class Maximum {
public function tapBoyukArrayDeyeri($yeniarray) {
if(!empty($yeniarray)){
$boyuk = $yeniarray[0];
for ($i=1;$i<count($yeniarray);$i++){
if($yeniarray[$i]>$boyuk){
$boyuk=$yeniarray[$i];
}
}
return $boyuk;
}else{
return 'Array bosdur';
}
}
}
$maximum = new Maximum();
$yeniarray=[2,12,25,13,26,55];
echo $maximum->tapBoyukArrayDeyeri($yeniarray);
//class Maximum {
//
// public function getMaxOfArray($newArray) {
// if (!empty($newArray)) {
// $max = $newArray[0];
// for ($i = 1; $i < count($newArray); $i++) {
// if ($newArray[$i]> $max) {
// $max = $newArray[$i];
// }
// }
// return $max;
// } else {
// return 'Empty!';
// }
// }
//
//}
//
//$maximum = new Maximum();
//$myArray = [21, 12, 25, 35, 50]; //yoxladigim array
//echo $maximum->getMaxOfArray($myArray); //classa sorudugum soru