Ver Mensaje Individual
  #5 (permalink)  
Antiguo 01/10/2009, 15:52
Nisrokh
 
Fecha de Ingreso: septiembre-2009
Ubicación: Neuquén
Mensajes: 142
Antigüedad: 14 años, 7 meses
Puntos: 12
Respuesta: Enviar HTML en return de función?

O algo asi :p

Código php:
Ver original
  1. <?php
  2.  
  3. $_MONTHS = array
  4. (
  5.     'Enero',
  6.     'Febrero',
  7.     'Marzo',
  8.     'Abril',
  9.     'Mayo',
  10.     'Junio',
  11.     'Julio',
  12.     'Agosto',
  13.     'Septiembre',
  14.     'Octubre',
  15.     'Noviembre',
  16.     'Diciembre'
  17. );
  18.  
  19. function month_selector($name)
  20. {
  21.     global $_MONTHS;
  22.    
  23.     $select = '<select name="' .$name. '" id="' .$name. '">%s</select>';
  24.     $option = '<option value="%d">%s</option>';
  25.    
  26.     for ($i = 0; $i < count($_MONTHS); $i++) {
  27.         $month_option.= sprintf($option, $i, $_MONTHS[$i]);
  28.     }
  29.    
  30.     return sprintf($select, '<option selected="selected">-- Mes --</option>' .$month_option);
  31. }
  32.  
  33. print month_selector('meses');
  34.  
  35. ?>