Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Wyswietlanie co drugiego znaku.
Domson502
post
Post #1





Grupa: Zarejestrowani
Postów: 10
Pomógł: 0
Dołączył: 16.05.2016

Ostrzeżenie: (0%)
-----


function everySecondCharacter($input) {
$output = '';

dump($output);
}

everySecondCharacter('War, has never been so much fun.');
everySecondCharacter('All You Need Is Love.');
everySecondCharacter('Heard ten thousand whispering and nobody listening.');




Jak z tych 3 zdan wyciagnac co 2 znak ? Wiem jak wyciagac powiedzmy 5 pierwszych znakow.
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
Domson502
post
Post #2





Grupa: Zarejestrowani
Postów: 10
Pomógł: 0
Dołączył: 16.05.2016

Ostrzeżenie: (0%)
-----


Ogarnalem juz. Wystarczylo dac
  1. function everySecondCharacter($input) {
  2. $output = '';
  3.  
  4. for ($i = 0; $i < strlen($input); $i+=2) {
  5. $output .= $input[$i];
  6. }
  7. dump($output);
  8. }
  9.  
  10. everySecondCharacter('War, has never been so much fun.');
  11. everySecondCharacter('All You Need Is Love.');
  12. everySecondCharacter('Heard ten thousand whispering and nobody listening.');

  1. $output .= $input[$i];


Ten post edytował Domson502 16.05.2016, 11:21:48
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 16.10.2025 - 05:18