Jump to content

i need help with "for"


nerya

Recommended Posts

$alphabets = array(1=>'a',2=>'b',3=>'c',4=>'d');

//as you need to print 5 z's at last -> loop the fisrt loop for 5

for($outer = 1;$outer <= 5;$outer++) {

foreach($alphabets as $alpha) {

 

for($i=1;$i<=$outer;$i++)

print $alpha;

 

print "\n";

}

 

}

Link to comment
Share on other sites

Do you realize how long that will take and how many strings you will be generating?

 

Ken

i need that for only to realize how it's work

in my system i will use that .....

i will get "word" like "abcc"

and I need to print what's the next word

in this case after "abcc" is"abcd"

 

so i need something like that

Link to comment
Share on other sites

lol i did try n post that but because someone posted it didnt really go through

 

hey he asked for a stupid code lol i gave him one

 

he cold seperate the code lol and start it from another bit instead a

 

like

 

$as = 'aaadcb';

for ( $counter = 0; $counter< 100 ; $counter++) {

 

    echo $as.'

';

   $as++;

}

 

 

so its first value would be 'aaadcb' and then 'aaadcc' and so on i did give him up 100 output lol he can chnage it till it crashes the browser or times out lol

 

fairly simple

Link to comment
Share on other sites

lol believe it or not this was some code that was used long time ago to crash computers

when computers had little processors back in the days lol

 

hackers felt genius of that at the time lol

 

but they used it on visual basic or java or them programming languages

 

more like a virus or something lol n set it up to run on start up lol

Link to comment
Share on other sites

hi

$as = 'az';

for ( $counter = 0; $counter< 3 ; $counter++) {

 

    echo $as.'';

    $as++;

}

 

it's good

but i want to save like that and print

 

$as = 'az';

for ( $counter = 0; $counter< 1 ; $counter++) {

 

    $as=$as.'';

    $as++;

}

echo $as

 

why it's doesn't work?????

Link to comment
Share on other sites

hi

$as = 'az';

for ( $counter = 0; $counter< 3 ; $counter++) {

 

     echo $as.'';

    $as++;

}

 

it's good

but i want to save like that and print

 

$as = 'az';

for ( $counter = 0; $counter< 1 ; $counter++) {

 

    $as=$as.'';

    $as++;

}

echo $as

 

why it's doesn't work?????

 

Because you are resetting the variable $as within the loop.

Link to comment
Share on other sites

$as = 'a';

for ( $counter = 0; $counter< 1000000 ; $counter++) {

 

     echo $counter.'-'.$as.'<br />';

$as++;

}

 

 

lol

this is funny 177144 - jbag

 

lol so u see it takes a long time lol but gives the guy the result lol

 

valtido you say "lol" to much. there is no need for it, its annoying.

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.