-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPangrams.php
More file actions
26 lines (21 loc) · 720 Bytes
/
Pangrams.php
File metadata and controls
26 lines (21 loc) · 720 Bytes
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
<?php
/*
* Complete the 'pangrams' function below.
*
* The function is expected to return a STRING.
* The function accepts STRING s as parameter.
*/
function pangrams($s) {
// Write your code here
// Create an array of all uppercase letters
$alphas = range('A', 'Z');
// Convert the input string to uppercase to make the check case-insensitive
$s = strtoupper($s);
// Check if each letter in the alphabet exists in the string
foreach ($alphas as $letter) {
if (strpos($s, $letter) === false) {
return "not pangram"; // If a letter is missing, return "not pangram"
}
}
return "pangram"; // If all letters are found, return "pangram"
}