Ver Mensaje Individual
  #3 (permalink)  
Antiguo 24/05/2010, 20:46
Avatar de wiwi74
wiwi74
 
Fecha de Ingreso: marzo-2008
Mensajes: 515
Antigüedad: 16 años, 1 mes
Puntos: 10
Respuesta: problemas con un array bidimensional de php

Mira este codigo:

Cuando lo pruebes ejecuta uno, luego el otro, para que no halla conflictos, ya que no les cambie el nombre a los array's






//si $x fuera numerico el array seria indexado numericamente (indice => valor)
$cant_suc[0][1]=20;
//array(0 => array(1 => 20));
$total_suc[0][1]=200;
//array(0 => array(1 => 200));

for($i=0;$i<sizeof($cant_suc);$i++){
foreach($cant_suc[$i] as $k_cant => $v_cant){
echo "<li>".$k_cant ." ". $v_cant;
}

foreach($total_suc[$i] as $k_total => $v_total){
echo "<li>".$k_total ." ". $v_total;
}
}


/*
//si $x fuera string el array seria asociativo (nombre => valor)
$cant_suc["indice"][1]=20;
//array("indice" => array(1 => 20));
$total_suc["indice"][1]=200;
//array("indice" => array(1 => 200));

for($i=0;$i<sizeof($cant_suc);$i++){

foreach($cant_suc['indice'] as $k_cant2 => $v_cant2){
echo "<li>".$k_cant2." ".$v_cant2;
}

foreach($total_suc['indice'] as $k_total2 => $v_total2){
echo "<li>".$k_total2." ".$v_total2;
}
}
*/