Reeks genereren

Gestart doorMerlin5 reacties238 weergaven

6 berichten · pagina 1 van 1

Merlin

Lid · Topicstarter

Berichten
1.928
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Hoi!

Kan iemand mij uitleggen (want volgens mij is dit echt drie lijnen code ofzo) hoe ik een reeks genereer van aaa t/m zzz? Dus als t goed is krijg je dan een output met 17.576 rijen van drie letters.

Merci! yes_new
0
Berichten
3.112
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Waarom niet in Webwereld? sadley
foreach(range(A, Z) as $een) {
    foreach(range(A, Z) as $twee) {
        foreach(range(A, Z) as $drie) {
            echo $een . $twee . $drie . PHP_EOL;
        }
    }
}
0
Merlin

Lid · Topicstarter

Berichten
1.928
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Goed punt, je bent in ieder geval wel een held voor je snelle reactie, thanks! smile
0
Berichten
35.796
Reputatie
1
Punten
0,00
Lid sinds
Laatst gezien
Of zo:

[COLOR= #0000BB]<?php
$letter[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]AAA[/COLOR][COLOR= #007700];[/COLOR]

[URL="http://www.php.net/while"]while[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$letter[/COLOR] [COLOR= #007700]<[/COLOR] [COLOR= #DD0000]ZZZ[/COLOR][COLOR= #007700])
{[/COLOR]
    
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$letter[/COLOR][COLOR= #007700]++.[/COLOR]PHP_EOL[COLOR= #007700];
    
}[/COLOR]


alleen stopt ie bij ZZY, ook als ik de < door <= vervang. confused
0
Berichten
3.112
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Lennard schreef:
Of zo:

[COLOR= #0000BB]<?php
$letter[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]AAA[/COLOR][COLOR= #007700];[/COLOR]

[URL="http://www.php.net/while"]while[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$letter[/COLOR] [COLOR= #007700]<[/COLOR] [COLOR= #DD0000]ZZZ[/COLOR][COLOR= #007700])
{[/COLOR]
    
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$letter[/COLOR][COLOR= #007700]++.[/COLOR]PHP_EOL[COLOR= #007700];
    
}[/COLOR]
alleen stopt ie bij ZZY, ook als ik de < door <= vervang. confused
Nooit geweten dat je letters ook kon optellen confused
[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/for"]for[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$letter[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"AAA"[/COLOR][COLOR= #007700];;[/COLOR] [COLOR= #0000BB]$letter[/COLOR][COLOR= #007700]++) {[/COLOR]

    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$letter[/COLOR] [COLOR= #007700].[/COLOR] PHP_EOL[COLOR= #007700];[/COLOR]

    [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$letter[/COLOR] [COLOR= #007700]==[/COLOR] [COLOR= #DD0000]"ZZZ"[/COLOR][COLOR= #007700])[/COLOR] [URL="http://www.php.net/break"]break[/URL][COLOR= #007700];
}[/COLOR]


Zo gaat hij wel tot ZZZ.
0
Berichten
35.796
Reputatie
1
Punten
0,00
Lid sinds
Laatst gezien
Perry schreef:
Eerdere citaten tonen
Lennard schreef:
Of zo:
[COLOR= #0000BB]<?php
$letter[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]AAA[/COLOR][COLOR= #007700];[/COLOR]

[URL="http://www.php.net/while"]while[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$letter[/COLOR] [COLOR= #007700]<[/COLOR] [COLOR= #DD0000]ZZZ[/COLOR][COLOR= #007700])
{[/COLOR]
    
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$letter[/COLOR][COLOR= #007700]++.[/COLOR]PHP_EOL[COLOR= #007700];
    
}[/COLOR]


alleen stopt ie bij ZZY, ook als ik de < door <= vervang. confused
Nooit geweten dat je letters ook kon optellen confused
[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/for"]for[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$letter[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"AAA"[/COLOR][COLOR= #007700];;[/COLOR] [COLOR= #0000BB]$letter[/COLOR][COLOR= #007700]++) {[/COLOR]

    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$letter[/COLOR] [COLOR= #007700].[/COLOR] PHP_EOL[COLOR= #007700];[/COLOR]

    [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$letter[/COLOR] [COLOR= #007700]==[/COLOR] [COLOR= #DD0000]"ZZZ"[/COLOR][COLOR= #007700])[/COLOR] [URL="http://www.php.net/break"]break[/URL][COLOR= #007700];
}[/COLOR]


Zo gaat hij wel tot ZZZ.

Nice thumbsup
Ik ook niet, maar dacht dat het misschien wel zou werken. yummie
0

Jouw reactie

Deel je idee, stel een vraag of help een ander verder.

Editor laden…

Praat mee met de One2xs-community.

Inloggen om te reageren