Skip to content

Commit 287f23a

Browse files
author
Amir-16
committed
520
1 parent f553e18 commit 287f23a

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

Easy/520. Detect Capital/solution.php

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
3+
class Solution {
4+
5+
6+
// @param String $word
7+
// @return Boolean
8+
function detectCapitalUse($word) {
9+
10+
$value = strlen($word);
11+
//echo $value;
12+
13+
if($value ==1){
14+
return true;
15+
}else if($value >1){
16+
17+
if(ctype_upper($word)){
18+
return true ;
19+
}else{
20+
21+
return false;
22+
}
23+
}
24+
else{
25+
for ($i = 1; $i < $value; $i++){
26+
if($word[$i]== $word[1]){
27+
return true;
28+
}
29+
else{
30+
return false;
31+
}
32+
}
33+
34+
35+
}
36+
37+
}
38+
}
39+
40+
41+
$solution = new Solution();
42+
$solution->detectCapitalUse("FlaG");
43+
44+
?>

0 commit comments

Comments
 (0)