Ver Mensaje Individual
  #2 (permalink)  
Antiguo 28/06/2011, 11:53
Avatar de repara2
repara2
 
Fecha de Ingreso: septiembre-2010
Ubicación: München
Mensajes: 2.445
Antigüedad: 13 años, 7 meses
Puntos: 331
Respuesta: Problema con arrays

Ahí te paso un ejemplo simple:

Código PHP:
Ver original
  1. <?php
  2. $arrayViejo = array(0 => 2, 1 =>  "a", 2 => 2000, 3 => 2011, 4 => "x", 5 =>  "c", 6 =>  22, 7 =>  true, 8 => "+");
  3. $nuevoarray = array();
  4. echo "<h5>Array viejo:</h5>";
  5. print_r($arrayViejo);
  6. $i = 0;
  7. foreach ($arrayViejo as $key => $value) {
  8.     if(eregi("2011",$value))$value = str_replace("2011","KK!",$value);
  9.     $nuevoarray[$key] = $value;
  10.     $i++;
  11. }
  12.  
  13. echo "<h5>Nuevo:</h5>";
  14. print_r($nuevoarray);
  15. ?>

Salu2!
__________________
Fere libenter homines, id quod volunt, credunt.