-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGlobalArray.php
65 lines (57 loc) · 1013 Bytes
/
GlobalArray.php
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
63
64
65
<html>
<head />
<body>
<?php
$globalArray = range(20, 1000, 37);
function IsPrimeNumber($number)
{
$isPrime = true;
for($i = 2; $i < $number; $i++)
{
if($number % $i == 0)
{
$isPrime = false;
}
}
return $isPrime;
}
function PrintThirdPrime()
{
global $globalArray;
$primeNumberCounter = 0;
foreach($globalArray as $number)
{
if(IsPrimeNumber($number))
{
$primeNumberCounter++;
}
if ($primeNumberCounter >= 3)
{
printf("%d\n", $number);
?>
<br />
<?php
break;
}
}
}
function CheckExistance()
{
global $globalArray;
foreach($globalArray as $number)
{
if($number == 871)
{
printf("The number 871 exists.\n");
?>
<br />
<?php
}
}
printf("The number 146,284 does not exist.\n");
}
PrintThirdPrime();
CheckExistance();
?>
</body>
</html>