Jump to content

ComputerColumbus

Members
  • Posts

    16
  • Joined

  • Last visited

Posts posted by ComputerColumbus

  1. I'm trying my best, especially since I'm learning on CodeAcademy! Unfortunately, their idea of learning is to push you into new topics. This excercise was slightly ahead of my knowledge. I'm also reading Paul Hudson's PHP ebook. It's steadier and goes more into detail.

     

    However, it is amazing how much I've been learning on this forum! :pirate:

  2. I need a simpler code. I am a beginner and I'm trying to print a random letter of my name for the first time.

     

    This should work, right?

     

      $myName = "Alison";
       $randomPosition = rand(0, 5);
       substr($myname, $randomPosition, 1)
       echo $randomPosition;

  3. This is what I have now but it still doesn't work...It prints Random letter from Alison: 'Alison'.

     

    $myName = "Alison";
       $randomPosition = rand(0, 5);
       echo "Random letter from $myName: 'Alison'";

  4. Hi there,

     

    I'm learning how to code on CodeAcademy. In one of the lessons it says that substr() treats character in a string as a zero-indexed array, and that the first letter of my name "Alison" is at position zero and the last letter at position -1. Why is my last letter name at position -1? Shouldn't it be at position 6?

     

    I'm trying to print a random letter from my name with this code. So far I wasn't able to.

     

     $myname = "Alison";

      

     $partial = substr($myname, 0, 3);

     

     print rand(a, n);

     

     Any advice would be appreciated...

     

     Regards,

     

     ComputerColumbus :pirate:

    CodeAcademy says that the letter "n" should be at position -1

  5. Hi there,

     

    I'm learning how to code on CodeAcademy. In one of the lessons it says that substr() treats character in a string as a zero-indexed array, and that the first letter of my name "Alison" is at position zero and the last letter at position -1. Why is my last letter name at position -1? Shouldn't it be at position 6?

     

    I'm trying to print a random letter from my name with this code. So far I wasn't able to.

     

     $myname = "Alison";
      

     $partial = substr($myname, 0, 3);
     

     print rand(a, n);

     

     Any advice would be appreciated...

     

     Regards,

     

     ComputerColumbus :pirate:

  6. 1 <!DOCTYPE html>
    2 <html>
    3  <head>
    4        <title>Your own do-while</title>
    5       <link type='text/css' rel='stylesheet' href='style.css'/>
    6   </head>
    7   <body>
    8       //write your do-while loop below
    9      <?p
    10     $red = "exciting";
    11      do {
    12         echo "<p>It's $red to be red.</p>";
    13         $red = false;
    14    } while ($red = "exciting");
    15   ?>
    16   </body>0
    17  </html>

     

    This is the error message that it gives me: Parse error: syntax error, unexpected T_VARIABLE on line 10

  7. Hell Valendor,

     

    I added the double or single quotes. It still doesn't work. It has issue with line 1 ---> red = "exciting";

     

    Hansford,

     

    I tried adding at the bottom: $red = false; It's supposed to stop the loop, right? It still doesn't work.

  8. Hi,

     

    I'm learning PHP on CodeAcademy and for one of the lessons, I'm supposed to create my very own do/while loop. Here it is:

     

    <?php
           $red = exciting;
             do {
                  echo "<p>It's $red to be red.</p>";
           } while ($red == exciting);
        ?>

     

    Not sure why it's not going through. It keeps giving me an error. Can you please help?

     

    Best regards, ComputerColumbus :pirate:

  9. I'm new to PHP.  I first started my computer science endeavour a few months ago on CodeAcademy. At the moment I hold the basics of HTML and CSS but PHP is whole new story! Definintely a lot more going on. Nevertheless, I look forward to this challenge!

     

    I joined <? PHP Freaks to learn and help others. See your around the PHP! :happy-04:

×
×
  • 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.