Ciao a tutti,

sto utilizzando uno script PHP che parsa un file XML (con SAX) che ricrea una struttura html con diverse textarea.
Vorrei inserire un indice progressivo ad ogni textarea tipo:

Codice PHP:
<textarea rows="20" cols="55" name="1" >testo 1</textarea>
<
textarea rows="20" cols="55" name="2" >testo 2</textarea
Lo script è questo:

Codice PHP:
$count=1// variabile per incrementare l'indice della textarea

  
function start_element($parser$element_name$element_attrs) {
    switch (
$element_name) {
      case 
'P';
      echo 
'<textarea rows="10" cols="55" name="'.$count.'">';
      break;

    }
  }
  
  function 
end_element($parser$element_name) {
    switch (
$element_name) {
      case 
'P';
      echo 
'</textarea>';
      break;

    }
  }
  
  function 
character_data($parser$data) {
   echo 
htmlentities($data);
  }
  
  
$parser xml_parser_create();
  
xml_set_element_handler($parser'start_element''end_element');
  
xml_set_character_data_handler($parser'character_data');
  
  
$fp fopen('chapter01.xml''r') or die ("Cannot open xml file!");
  
  
  while (
$data fread($fp4096)) {
    
xml_parse($parser$datafeof($fp))
    or die(
sprintf('XML ERROR: %s at line %d',
    
xml_error_string(xml_get_error_code($parser)),
    
xml_get_current_line_number($parser)));
    
$count++;
  }
  
  
xml_parser_free($parser); 
L'ultimo ciclo while, legge l'xml, lo parsa e lo stampa. Come faccio a dirgli di incrementare anche la variabile $count?