Last active
January 24, 2018 03:32
-
-
Save hersan/f71e9fef74133e934ad3ff3b18777523 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| for($i = 0; $i <= 100; $i++) { | |
| if ( $i % 2 == 0 ) { | |
| echo "$i buzz \n"; | |
| } | |
| if ( $i % 3 == 0) { | |
| echo "$i fizz \n"; | |
| } | |
| } | |
| $string = 'zapato'; | |
| function first_character_repeated($string) { | |
| for($i = 0; $i < strlen($string); $i++) { | |
| $char = $string[$i]; | |
| for($j = $i + 1; $j < strlen($string); $j++) { | |
| if($char == $string[$j]) { | |
| return $char; | |
| } | |
| } | |
| } | |
| } | |
| print_r(first_character_repeated($string)); | |
| $array = [ 1, 2, 3, 4, 5, 6, 7, 8, 9 ]; | |
| function recursive_iteration($array, $start = 0) { | |
| if($start < count($array)) { | |
| echo $array[$start]; | |
| recursive_iteration($array, ++$start); | |
| } | |
| } | |
| recursive_iteration($array); | |
| $matrix = [ | |
| [1, 5, 8, 6], | |
| [4, 8, -5, 4] | |
| ]; | |
| $transponsed = array_map(null, ...$matrix); | |
| print_r($transponsed) . "\n\n"; | |
| function transposed_matrix($matrix){ | |
| $columns = count($matrix[0]); | |
| $newMatrix = []; | |
| for($i = 0; $i <= $columns; $i++) { | |
| $row = array_column($matrix, $i); | |
| $newMatrix[] = $row; | |
| } | |
| return $newMatrix; | |
| } | |
| $transponsed = transposed_matrix($matrix); | |
| print_r($transponsed); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment