views:

23

answers:

1

Iam calling a PHP custom function with different parameters which returns a 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 the custom function in the controller and assigning this values to the view variable details

$arr['INDEX_NAME'] = get_list_values('A','B','G');
$view->details  = $arr;

How do i assign this details to hidden variable if the array count is 1 and if the array count is more than 1 have to assign to 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 do i print the value if the array value is 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 do i iterate the values over here if the array value is more than 1
    </select>
   </td>

  </tr>
 </table>
 <?php } ?>
+1  A: 

for the first one:

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

for the second one:

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