php - How do i assign values to the Select Box or hidden value retrived from function -


iam calling php custom function different parameters returns different arrays based on parameters .

//array1 array(1) {   ["index_name"]=>   array(1) {     ["xerox print "]=>     string(8) "xerox value"   } }  //array2  array(1) {   ["index_name"]=>   array(2) {     ["xerox print"]=>     string(8) "test2"     ["xerox print1"]=>     string(8) "test1"   } } 

iam using zf framework iam calling custom function in controller , assigning values view variable details

$arr['index_name'] = get_list_values('a','b','g'); $view->details  = $arr; 

how assign details hidden variable if array count 1 , if array count more 1 have assign select box

     <?php   if (is_array($this->details['index_name']) && count($this->details['index_name'])==1) {  ?>   <input type="hidden" name="sel_printq" id="sel_printq" value="<?php  // how print value if array value 1?>">  <?php   } else {  ?>  <table>   <tr>     <th colspan="2" class="coltextleft">list</th>   </tr>   <tr>    <td>select value</td>    <td>     <select id="selctbox" name="selctbox">      <option selected value="">please select valuer</option>      //how iterate values on here if array value more 1     </select>    </td>    </tr>  </table>  <?php } ?> 

for first one:

$val = array_values($this->details['index_name']); echo $val[0]; 

for second one:

foreach($this->details['index_name'] $key=>$val){    echo "<option value='$key'>$val</option>"; } 

Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -