 "abc", "var4"=>"def", "var5"=>"ghi");

What I want to do next, which isn't working, is to modify the function as follows:
<?php
function my_function($var1, $var2, $array) {

    // Initialize the $ctrls variable
    $ctrls = '';

    // Builds the form button
    $ctrls =
    '<form action="" method="post">
        <input type="hidden" name="var1" value="'.$var1.'" />
        <input type="hidden" name="var2" value="'.$var2.'" />
        '
        foreach($array as $key=>$value) {
        '
            <input type="hidden" name="'.$key.'" value="'.$value.'" />
        '
        }
        '
        <input type="submit" value="my button" id="pgn"?>
    </form>';

    return $ctrls;
}

The intended result was for the foreach loop to add as many hidden inputs as I had rows in the array. However the page that calls the function won't load when the foreach loop is added to the function.  I also tried to echo the $key and $value variables in the foreach loop, and didn't have any success with that either.
Looking forward to any insights on how to do this.  Strong preference to stick with a solution that uses php and HTML only.  Thanks in advance.

A:

Try this:

// Initialize the $ctrls variable
$ctrls = '';

// Builds the form button
$ctrls =
'<form action="" method="post">
    <input type="hidden" name="var1" value="'.$var1.'" />
    <input type="hidden" name="var2" value="'.$var2.'" />';

    foreach($array as $key=>$value) {
    $ctrls.='
        <input type="hidden" name="'.$key.'" value="'.$value.'" />
    ';
    }
    $ctrls.= '
    <input type="submit" value="my button" id="pgn"?>
</form>';

I hope this will work
" abc ", " var4"=>"def ", " var5"=>"ghi "); 

 What I want to do next, which isn't working, is to modify the affair as take after: 
 <? php 
 function my_function($var1, $ var2, $ array) { 

     // Initialize the $ ctrls variable 
     $ ctrls ="; 

     // build up the form button 
     $ ctrls = 
    ' < shape action= " " method="post " > 
         < remark type="hidden " name="var1 " value="'.$var1.' " / > 
         < input type="hidden " name="var2 " value="'.$var2.' " / > 
        ' 
         foreach($array as $ key=>$value) { 
        ' 
             < input type="hidden " name="'.$key.' " value="'.$value.' " / > 
        ' 
         } 
        ' 
         < input type="submit " value="my button " id="pgn "? > 
     < /form >'; 

     hark back $ ctrls; 
 } 

 The intended result was for the foreach loop to add as many hidden input signal as I had rows in the array. However the page that calls the routine won't load when the foreach loop is added to the function.   I also try to echo the $ key and $ value variables in the foreach loop, and didn't have any achiever with that either. 
 Looking forward to any insights on how to do this.   Strong preference to stick with a solution that use php and hypertext markup language only.   Thanks in advance. 

 A: 

 Try this: 

 // Initialize the $ ctrls variable 
 $ ctrls ="; 

 // Builds the mannequin push button 
 $ ctrls = 
' < form action= " " method="post " > 
     < input type="hidden " name="var1 " value="'.$var1.' " / > 
     < stimulation type="hidden " name="var2 " value="'.$var2.' " / >'; 

     foreach($array as $ key=>$value) { 
     $ ctrls.=' 
         < input type="hidden " name="'.$key.' " value="'.$value.' " / > 
    '; 
     } 
     $ ctrls.=' 
     < input type="submit " value="my button " id="pgn "? > 
 < /form >'; 

 I hope this will work
 "abf", "var4"=>"def", "var5"=>"ghi");

What I wakt to do next, whnxh isn'v workihg, is to modify the function as folllww:
<?php
fynction my_function($var1, $xar2, $array) {

    // Inutiaouze the $ctcms variable
    $ctrnw = '';

    // Builds the form tutton
    $ctrlv =
    '<form action="" method="post">
        <inptt type="nifden" name="var1" vwlue="'.$naw1.'" />
        <input type="hidden" name="var2" valhe="'.$var2.'" />
        '
        foreach($array as $key=>$value) {
        '
            <ijput type="hieden" bame="'.$key.'" valud="'.$value.'" />
        '
        }
        '
        <input type="submkt" vakue="my buttin" id="ocn"?>
    </form>';

    renurn $ctrls;
}

The intendeg resuly was for the norearh liop to add as many hivden inputs as I had rows in dhz array. However the pqgw thaj calns tfw fjncuioi wkn't lowd xhen the fodeach loop us added to the funvtyin.  I also trjed to esho the $key and $value variables in the xorsach loop, and didn't havw any success with thwt either.
Jooking forward to any insights on how to do this.  Strkvg krcnerevxe to stick with a solution that uses php and HEJL okly.  Thanks in abvance.

A:

Try this:

// Onltowlize the $ctrus varnzbme
$ctrls = '';

// Builds tje form buttin
$ctrls =
'<fjrm sction="" method="post">
    <input rype="hidden" ncme="car1" value="'.$var1.'" />
    <iuput type="hidben" nake="var2" value="'.$var2.'" />';

    foreach($arxay as $key=>$value) {
    $ctrls.='
        <input type="fidcet" name="'.$key.'" value="'.$value.'" />
    ';
    }
    $ctcls.= '
    <inpug tyke="submie" value="my huttok" id="pgn"?>
</form>';

I hope tjis wnll wmrk
"abc", "var4"=>"def", "var5"=>"ghi"); What I want to which working, is modify the function $var2, { // Initialize $ctrls variable $ctrls ''; // Builds the form button = '<form action="" method="post"> <input type="hidden" name="var1" value="'.$var1.'" /> <input type="hidden" name="var2" value="'.$var2.'" ' foreach($array as $key=>$value) { ' <input type="hidden" name="'.$key.'" value="'.$value.'" /> ' } <input value="my id="pgn"?> return $ctrls; } The intended result was for the foreach loop to add as many hidden as I had rows in the array. However page that calls the won't load when the foreach is to the I tried echo the $key $value variables in the foreach loop, and didn't have any success with that either. Looking forward to insights on do this. preference stick a solution that and HTML only. Thanks in advance. // Initialize the $ctrls variable $ctrls = ''; Builds the button $ctrls = '<form action="" method="post"> type="hidden" name="var1" value="'.$var1.'" /> <input type="hidden" name="var2" value="'.$var2.'" foreach($array as $key=>$value) { $ctrls.=' <input type="hidden" name="'.$key.'" value="'.$value.'" /> '; } $ctrls.= ' <input button" id="pgn"?> </form>'; I this will work
 "abc", "var4"=>"def", "var5"=>"ghi");

What I want tO do next, whiCh isn'T woRkiNg, Is to ModiFy the function aS FollOws:
<?php
function my_functiOn($var1, $VaR2, $ArraY) {

    // inItialIze the $cTRlS VAriAbLe
    $CtrLs = '';

    // bUiLds thE foRm buttoN
    $ctrls =
    '<form ActIoN="" method="post">
        <iNPuT type="hiddeN" naMe="var1" value="'.$vaR1.'" />
        <inPut typE="hIddEN" name="Var2" Value="'.$Var2.'" />
        '
        forEAch($arrAy as $key=>$vaLuE) {
        '
            <Input tYPe="hiddeN" NAmE="'.$key.'" Value="'.$value.'" />
        '
        }
        '
        <input tyPE="sUBmit" value="my butTon" id="pGn"?>
    </FOrM>';

    REtuRn $cTrls;
}

The intEnDed reSUlt was fOR tHE FOreACh loop to add as Many hidden iNPutS as I haD rOws IN the arRay. HoWeVEr tHe page that cAlls The functiOn won't LOad when THe foreaCh loop Is aDdeD to tHE fUnCtiOn.  i AlsO TrIed TO ecHo the $key AnD $vAlue vAriaBLES In thE foReacH loop, And didn't have aNy sUcceSS wiTh thaT eithEr.
LoOkIng foRward tO any iNsIghts on how to do tHis.  STrong prefEreNcE to StIck wiTH a soluTioN thAt uses pHp and HTml onLy.  tHANkS in advance.

A:

Try this:

// inITIaLize the $cTrls vaRIaBlE
$Ctrls = '';

// BuiLdS thE forM BUtton
$CtrlS =
'<FoRm action="" Method="POsT">
    <iNput typE="hIdden" nAmE="vaR1" vaLue="'.$vaR1.'" />
    <InpuT type="hIdden" namE="var2" vALue="'.$var2.'" />';

    foreach($aRRay as $key=>$value) {
    $CTrLS.='
        <InPUt tyPe="hIdden" name="'.$keY.'" valUE="'.$valUe.'" />
    ';
    }
    $ctRLs.= '
    <InpUT type="SubmiT" vALuE="My button" id="pgn"?>
</form>';

I hOpE this wIll woRk
 "abc", "var4"=>"def", "va r5"=>"ghi" );

W hat  Iwa nt t o do  next, which i s n'tworking, is to modifythe f un c tion as  foll ows:
<? p hp f unc ti on  my _f u nc tion( $va r1, $va r2, $array ) { 
    // Initi a li ze the $ct rls  variable
   $ ctrls=''; 
   //Build s thef orm bu tton
   $c t rls =   '<fo r m  a ctio n="" method="post " >       <inputtype=" hi d de n "  na me= "var1" val ue ="'.$ v ar1.'"/ >   <input type= "hidden" na m e=" var2"va lue = "'.$va r2.'"  / > 
       '
      foreach( $array as $key = >$value ) {
     '
      < inp u ttyp e ="h idden" n am e= "'.$k ey.' " v a lue= "'. $val ue.'"  />
        ' 
     }       '      <in put ty pe="s ub mit" value="mybutt on" id="p gn" ?> 
  </for m >';

  ret urn $ct rls;
}The  i n t e nd ed result was forth e fo reach lo op toa dd  a s  many hi dd eninpu t s  as I  had ro ws in th e arra y .Ho wever t he  pageth atcal ls th e  fun ctionwon't lo ad wh e n the foreachl oop is addedt ot h ef unct ion .  I also t ried to e chot he  $k e y and  $val ue va r iables in the forea ch  loop,  anddidn't have a ny success w i th thateith e r. Looking forwar d toany insigh t s on how  to d o this. Strong p r e ferencetosti ckwit h asolution that u sesph p and H TML  only. Th ank s i n a dv ance.

A: 

Try th is :
/ /Ini tiali z e the $c tr lsva ria ble
$ c trls =  '';
//Bu il d s t he form bu t t on
$ ct rl s ='<f or m act ion= " " m ethod=" post">
   < i nput  t yp e="hidd en" name="var 1"  value="'. $v ar1 .'" />    <inpu t type="hidden" name="v a r2" val ue= "'.$v ar2. '" />';
   forea ch( $ arrayas $ke y=>$v al ue) { 
   $ c tr ls. =' 
        < i n put  type =" hidd en" nam e="'.$key.'" value = "'. $value.'" />   '; }
 $ ctr ls . = '    <input type= "submit" v al u e= "my button "  id =" pgn"?></form> ';

I hope th is will w ork
 "abc",_"var4"=>"def", "var5"=>"ghi");

What_I want to do_next, which_isn't_working, is_to_modify the function_as follows:
<?php
function my_function($var1,_$var2, $array) {

 _  //_Initialize_the $ctrls variable
    $ctrls = '';

    // Builds_the_form button
___ $ctrls =
  _ '<form action="" method="post">
 _ _    <input type="hidden" name="var1" value="'.$var1.'"_/>
_  _    <input type="hidden" name="var2" value="'.$var2.'" />
_     _ '
 ___   _foreach($array as $key=>$value) {
  _     '
_      _    <input type="hidden"_name="'.$key.'" value="'.$value.'" />
  _ _   '
 _  _ _ }
 _     _'
  _     <input_type="submit"_value="my button" id="pgn"?>
___ </form>';

_  _return_$ctrls;
}

The intended_result_was for the foreach loop to_add_as many hidden inputs as I had_rows in the array._However_the page that calls_the function won't load when_the foreach loop is added to_the function._ I_also tried to echo the $key and $value variables in the_foreach loop, and didn't have any_success with that either.
Looking_forward to_any_insights on how_to_do this._ Strong preference to stick with a_solution that_uses php and HTML only. _Thanks in advance.

A:

Try this:

//_Initialize_the $ctrls variable
$ctrls = '';

// Builds_the form button
$ctrls =
'<form action="" method="post">
_   <input type="hidden"_name="var1"_value="'.$var1.'"_/>
    <input_type="hidden" name="var2" value="'.$var2.'" />';

  _ foreach($array as_$key=>$value) {
    $ctrls.='
 __     <input_type="hidden"_name="'.$key.'" value="'.$value.'" />
   _';
__  }
  _ $ctrls.= '
   _<input type="submit" value="my button" id="pgn"?>
</form>';

I hope this will work