@@ -15,7 +15,7 @@ |
||
| 15 | 15 | { |
| 16 | 16 | $count = 0; |
| 17 | 17 | $arrCount = count($arr); |
| 18 | - for ($i = 0; $i < $arrCount; $i++) { |
|
| 18 | + for ($i = 0; $i < $arrCount; $i++) { |
|
| 19 | 19 | for ($j = 0; $j < $arrCount; $j++) { |
| 20 | 20 | if ($arr[$i] == $arr[$j]) { |
| 21 | 21 | $count++; |
@@ -18,12 +18,12 @@ discard block |
||
| 18 | 18 | function persistence(int $num): int |
| 19 | 19 | { |
| 20 | 20 | // Ensure that $num is an integer |
| 21 | - $num = (int)$num; |
|
| 21 | + $num = (int) $num; |
|
| 22 | 22 | $total = 1; |
| 23 | 23 | |
| 24 | 24 | $numArray = str_split($num); |
| 25 | 25 | // Additional type check |
| 26 | - if (true===$numArray) { |
|
| 26 | + if (true === $numArray) { |
|
| 27 | 27 | return 0; |
| 28 | 28 | } |
| 29 | 29 | $numArrayCount = count($numArray); |
@@ -53,9 +53,9 @@ discard block |
||
| 53 | 53 | function altPersistence(int $num): int |
| 54 | 54 | { |
| 55 | 55 | // Ensure that $num is an integer |
| 56 | - $num = (int)$num; |
|
| 56 | + $num = (int) $num; |
|
| 57 | 57 | $splitNum = str_split($num); |
| 58 | - if (true===$splitNum) { |
|
| 58 | + if (true === $splitNum) { |
|
| 59 | 59 | return 0; |
| 60 | 60 | } |
| 61 | 61 | $count = 0; |
@@ -24,8 +24,8 @@ |
||
| 24 | 24 | { |
| 25 | 25 | return array_sum( |
| 26 | 26 | array_filter( |
| 27 | - range(1, $number-1), |
|
| 28 | - function ($item) { |
|
| 27 | + range(1, $number - 1), |
|
| 28 | + function($item) { |
|
| 29 | 29 | return $item % 3 == 0 || $item % 5 == 0; |
| 30 | 30 | } |
| 31 | 31 | ) |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | { |
| 33 | 33 | $counter = 0; |
| 34 | 34 | for ($counter; $startpeople < $endpeople; $counter++) { |
| 35 | - $startpeople = $startpeople * (1 + $percent / 100) + $aug ; |
|
| 35 | + $startpeople = $startpeople * (1 + $percent / 100) + $aug; |
|
| 36 | 36 | } |
| 37 | 37 | return $counter; |
| 38 | 38 | } |
@@ -40,5 +40,5 @@ discard block |
||
| 40 | 40 | // Alternate solution with ternary: |
| 41 | 41 | function altnbYear($startpeople, $percent, $aug, $endpeople) |
| 42 | 42 | { |
| 43 | - return $startpeople >= $endpeople ? 0 : 1 + nbYear((int)$startpeople * (1+$percent/100) + $aug, $percent, $aug, $endpeople); |
|
| 43 | + return $startpeople >= $endpeople ? 0 : 1 + nbYear((int) $startpeople * (1 + $percent / 100) + $aug, $percent, $aug, $endpeople); |
|
| 44 | 44 | } |
@@ -28,10 +28,10 @@ |
||
| 28 | 28 | $middle = $length / 2; |
| 29 | 29 | |
| 30 | 30 | if ($length % 2 == 0) { |
| 31 | - $returnedText = $text[$middle-1]; |
|
| 32 | - $returnedText.= $text[$middle]; |
|
| 31 | + $returnedText = $text[$middle - 1]; |
|
| 32 | + $returnedText .= $text[$middle]; |
|
| 33 | 33 | } |
| 34 | - $returnedText.= $text[$middle]; |
|
| 34 | + $returnedText .= $text[$middle]; |
|
| 35 | 35 | return $returnedText; |
| 36 | 36 | } |
| 37 | 37 | |
@@ -6,7 +6,7 @@ |
||
| 6 | 6 | function removeChar(string $string) |
| 7 | 7 | { |
| 8 | 8 | $removeFirst = substr($string, 1); |
| 9 | - $finalString = substr($removeFirst, 0, strlen($removeFirst)-1); |
|
| 9 | + $finalString = substr($removeFirst, 0, strlen($removeFirst) - 1); |
|
| 10 | 10 | return $finalString; |
| 11 | 11 | } |
| 12 | 12 | |
@@ -8,7 +8,7 @@ |
||
| 8 | 8 | function reverseSeq($varNumber) |
| 9 | 9 | { |
| 10 | 10 | $number = []; |
| 11 | - for ($i = $varNumber; $i > 0;$i--) { |
|
| 11 | + for ($i = $varNumber; $i > 0; $i--) { |
|
| 12 | 12 | array_push($number, $i); |
| 13 | 13 | } |
| 14 | 14 | return $number; |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | |
| 14 | 14 | function betterThanAverage($classPoints, $yourPoints) |
| 15 | 15 | { |
| 16 | - $average = array_sum($classPoints)/count($classPoints); |
|
| 16 | + $average = array_sum($classPoints) / count($classPoints); |
|
| 17 | 17 | if ($average < $yourPoints) { |
| 18 | 18 | return true; |
| 19 | 19 | } |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | // Alternate solution with ternary operator |
| 24 | 24 | function altbetterThanAverage($classPoints, $yourPoints) |
| 25 | 25 | { |
| 26 | - return array_sum($classPoints)/count($classPoints) < $yourPoints ? true : false; |
|
| 26 | + return array_sum($classPoints) / count($classPoints) < $yourPoints ? true : false; |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | // Another solution |
@@ -18,11 +18,11 @@ |
||
| 18 | 18 | */ |
| 19 | 19 | function descendingOrder(int $number): int |
| 20 | 20 | { |
| 21 | - $number = (int)$number; |
|
| 22 | - $arrayNumber = str_split($number); |
|
| 21 | + $number = (int)$number; |
|
| 22 | + $arrayNumber = str_split($number); |
|
| 23 | 23 | |
| 24 | - $arrayNumber = (array)$arrayNumber; |
|
| 25 | - arsort($arrayNumber); |
|
| 24 | + $arrayNumber = (array)$arrayNumber; |
|
| 25 | + arsort($arrayNumber); |
|
| 26 | 26 | |
| 27 | - return (int)implode($arrayNumber); |
|
| 27 | + return (int)implode($arrayNumber); |
|
| 28 | 28 | } |
@@ -18,11 +18,11 @@ |
||
| 18 | 18 | */ |
| 19 | 19 | function descendingOrder(int $number): int |
| 20 | 20 | { |
| 21 | - $number = (int)$number; |
|
| 21 | + $number = (int) $number; |
|
| 22 | 22 | $arrayNumber = str_split($number); |
| 23 | 23 | |
| 24 | - $arrayNumber = (array)$arrayNumber; |
|
| 24 | + $arrayNumber = (array) $arrayNumber; |
|
| 25 | 25 | arsort($arrayNumber); |
| 26 | 26 | |
| 27 | - return (int)implode($arrayNumber); |
|
| 27 | + return (int) implode($arrayNumber); |
|
| 28 | 28 | } |