array - probleme

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • array - probleme

    hallo leute!

    also ich habe mal wieder ein problem..

    über:

    PHP Code:
        
        $_GET
    []; 
    fange ich eine beliebige anzahl an variablen ab (0- ??)

    bsp.:

    PHP Code:
        
        $_GET
    ['option_1'];
        
    $_GET['option_2];
        $_GET['
    option_3'];
        $_GET['
    option_4];
        
    $_GET['option_5];
        $_GET['
    option_6];
        
    $_GET['option_7'];
        
    $_GET['option_8'];
        
    $_GET['option_9']; 
    diese ganzen varibalen möchte ich in ein array namens option speichern

    bsp.:

    PHP Code:
        
       $option
    [0] = $_GET['option_1'];
       
    $option[1] = $_GET['option_2'];
       
    $option[2] = $_GET['option_3'];
       
    $option[3] = $_GET['option_4'];
       
    $option[4] = $_GET['option_5'];
       
    $option[5] = $_GET['option_6'];
       
    $option[6] = $_GET['option_7'];
       
    $option[7] = $_GET['option_8'];
       
    $option[8] = $_GET['option_9']; 

    wie würdet ihr das machen..?!- ich hab leider überhaupt keine idee..



    bitte helft mir..!


    lg, harry d.

  • #2
    mit foreach
    Für Rechtschreibfehler übernehme ich keine Haftung!

    Comment


    • #3
      vorerst einmal danke für die schnell antwort aber leider weiss ich nicht ganz, was mir foreach hier bringen soll..?!


      mfg.- harry d.

      Comment


      • #4
        mach mal print_r($_GET) und überleg
        Für Rechtschreibfehler übernehme ich keine Haftung!

        Comment


        • #5
          Dann benutze halt eine for-Schleife.

          Comment


          • #6
            auch wenn ich jetzt wie der ärgste noob dastehe.. das hab ich echt nicht gewusst, dass die alle in einem array gespeichert werden.. *indenbodenverkriech*gg*


            vielen dank!!!



            lg, harry d.

            Comment


            • #7
              so.. habe jetzt das manuel auf www.php.net gelesen und auch hier im forum noch einmal gesucht, aber ich weiss leider trotzdem immer noch nicht, wie mit foreach() jetzt die variablen die im $_GET - array sind und mit option_ beginnen in ein das neue array option zu speichern..


              kann mir bitte noch einmal einer von euch einen tipp geben..


              lg, harry d.

              Comment


              • #8
                warum übergibst du den block nicht auch schon als array?

                ala
                $_GET['block']['option1']
                $_GET['block']['option2']
                $_GET['block']['option3']

                dann hast du bereits ein feines array unter $_GET['block'] , welches zu auch z.b. in eine session packen kannst.

                $_SESSION['block'] = $_GET['block']
                INFO: Erst suchen, dann posten![color=red] | [/color]MANUAL(s): PHP | MySQL | HTML/JS/CSS[color=red] | [/color]NICE: GNOME Do | TESTS: Gästebuch[color=red] | [/color]IM: Jabber.org |


                Comment


                • #9
                  oder etwas umständlicher:
                  PHP Code:
                  foreach($_GET AS $key=>$val)
                  $exp explode('_'$key):
                  if(
                  $exp['0'] == 'option')
                  {
                      
                  $arr[$exp['1']] = $val;

                  Für Rechtschreibfehler übernehme ich keine Haftung!

                  Comment


                  • #10
                    vielen dank für eure großartige unterstützung..!- jetzt funktioniert es wirklich einwandfrei..

                    hab es jetzt so gelöst:

                    PHP Code:

                    foreach($_GET AS $key=>$val)
                        {
                            
                    $exp explode('_'$key);
                            if(
                    $exp['0'] == 'option')
                            {
                                
                    $options[$exp['1']-1] = $val;
                            }
                        } 
                    danke noch einmal und eine gute nacht..



                    mfg.- harry d.

                    Comment

                    Working...
                    X