Jump to content

printJimy

Members
  • Posts

    11
  • Joined

  • Last visited

Posts posted by printJimy

  1. this is what appears to me

    post-133998-0-91363400-1354114611_thumb.jpg

     

    , the only thing that I changed is that i add an <br> inside of for loop

    like this:

     

    for($q = 1; $q <= $questions; $q++){//loop through number of questions required
    
    					echo "  <input name='questions[]' type='text' value='question $q' /><br/>\n";
    
    					for($opt = 1; $opt <= $choices; $opt++){//loop through number of options required
    
    					   echo "   <input name='choice[]' type='text' value='option $opt' /><br/>\n";
    
    					}
    [color=#ff0000]				  //here [/color]
    [color=#ff0000]				  echo "<br>";[/color]
    			}

    post-133998-0-91363400-1354114611_thumb.jpg

  2. And would you knock screws in with a hammer, or do the sensible thing and use a screwdriver?

     

    Ok , i said that im just learning how to use other loop in these case , but i do not use" for or while" when i work with array , because i know that foreach is constructed for that.

    So i just want to know how to use other loop to manipulate with array.

  3. also i have a question about how to output the key of array with the for loop .

    example this is an array and this array have 2 key 1 and 2 , how to output these keys .

    $vegetables=array (1=>"apples", 2=>"pear");

    and the output of this array i like to be (if it is possible) :

    1 apples
    2 pear
    

    without any special function like

    key();

    or something like this .

    Thanks

  4. Thank to all of you , i really understood issue now .

    Also when we have the key of array as a string , we need to use a string also in a loop , example like this ?

    is it the right ?

    <?php
    $mArr = array(
    "a"=>array(1, "string", 3, 4, 5),
    "b"=>array(7, 20, 43, 44, 25)
    );
    
    
    
    
    for ($i="a"; $i<= "b"; $i++)
    {
    
    
    for ($j=0;$j<count($mArr[$i]); $j++)
    {
    
    
    echo $mArr[$i][$j]." ";
    
    }
    echo"<br>";
    }
    ?>
    

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