Skip to content

Commit

Permalink
Merge pull request #162 from Fernandafmsf/challenges/2-palindromo/php…
Browse files Browse the repository at this point in the history
…/Fernandafmsf

Finalizando desafio 2
  • Loading branch information
lanjoni authored Oct 4, 2023
2 parents 66fdca4 + d13a849 commit 41b2e8b
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 1 deletion.
2 changes: 1 addition & 1 deletion challenges/0-hello-world/php/Fernandfmsf/helloworld.php
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<?php
echo 'Hello, World!';
echo 'Hello, World';
1 change: 1 addition & 0 deletions challenges/1-cubo-simples/php/Fernandafmsf/cubosimples.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
$number= $argv;

//funcao para percorrer todo o array. Definir a var $i como 1 é imprescindivel para o codigo funcionar, visto que $argv[0] é uma string (nome do projeto)
//count -> tamanho do array
function calcularCubo($number)
{
for($i=1; $i<count($number); $i++){
Expand Down
22 changes: 22 additions & 0 deletions challenges/2-palindromos/php/Fernandafmsf/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Submissão de Exercicio

**Exercicio:** 2 - Palindromos

**Nickname:** Fernandafmsf

**Nível Técnico:** - Estudante -

**Empresa:** - Nenhuma -

**Twitter**: https://twitter.com/dev_fernanda

**Dificuldade de Resolução:** - Baixa -

**Comentários:** Foi bom conhecer funçoes como strrev, que reverte as palavras e strtolower, que retorna a string com todos os caracteres em minuscolo

**Como rodar o desafio**:

Use o comando abaixo:
```bash
php palindromo.php argv1 argv2 argv3
```
18 changes: 18 additions & 0 deletions challenges/2-palindromos/php/Fernandafmsf/palindromo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php
$words=$argv;
function verifyPalindrome($word)
{

for($i=1;$i<count($word);$i++){

$word[$i] = strtolower($word[$i]); //transformando letras maiusculas em minusculas
if(strrev($word[$i]) != $word[$i]){
echo "false" . PHP_EOL;
}else{
echo "true".PHP_EOL;
}

}
}

verifyPalindrome($words);

0 comments on commit 41b2e8b

Please sign in to comment.