Quisiera saber si pueden ayudarme con un problema que no logro resolver.
Tengo una tabla mutidimensional "$genotype" que es el resultado de la lectura de un documento Excell gracias a la clase "phpExcellReader".
$genotype :
Cita:
Yo solo quiero recuperar los valores de la tabla $genotype['cells'] en donde hay 3 tablas, la primera tiene el nombre de un locus (es biologia da lo mismo), la tabla 2 tiene la talla del alelo 1 y la tercera tabla la talla del alelo 2. Asi, para recuperar los datos del primer locus y sus dos alelos corespondientes solo debo hacer:array(6) { ["maxrow"]=> int(0) ["maxcol"]=> int(0) ["numRows"]=> int(3) ["numCols"]=> int(15) ["cells"]=> array(3)
{ [1]=> array(14) { [2]=> string(5) "Pd_10" [3]=> string(5) "Pd_15" [4]=> string(5) "Pd_16" [5]=> string(5) "Pd_25" [6]=> string(5) "Pd_32" [7]=> string(5) "Pd_35" [8]=> string(5) "Pd_50" [9]=> string(5) "Pd_57" [10]=> string(5) "Pd_63" [11]=> string(5) "Pd_70" [12]=> string(5) "Pd_78" [13]=> string(5) "Pd_85" [14]=> string(5) "Pd_90" [15]=> string(5) "Pd_93" } [2]=> array(15)
{ [1]=> string(8) "Allele_1" [2]=> string(3) "123" [3]=> string(3) "119" [4]=> string(3) "111" [5]=> string(3) "201" [6]=> string(3) "287" [7]=> string(3) "176" [8]=> string(3) "206" [9]=> string(3) "257" [10]=> string(3) "141" [11]=> string(3) "215" [12]=> string(3) "136" [13]=> string(3) "149" [14]=> string(3) "137" [15]=> string(3) "159" } [3]=> array(15)
{ [1]=> string(8) "Allele_2" [2]=> string(3) "128" [3]=> string(3) "152" [4]=> string(3) "111" [5]=> string(3) "201" [6]=> string(3) "287" [7]=> string(3) "176" [8]=> string(3) "206" [9]=> string(3) "259" [10]=> string(3) "141" [11]=> string(3) "215" [12]=> string(3) "136" [13]=> string(3) "149" [14]=> string(3) "137" [15]=> string(3) "159" } }
["cellsInfo"]=> array(2) { [2]=> array(14) { [2]=> array(2) { ["raw"]=> int(123) ["type"]=> string(7) "unknown" } [3]=> array(2) { ["raw"]=> int(119) ["type"]=> string(7) "unknown" } [4]=> array(2) { ["raw"]=> int(111) ["type"]=> string(7) "unknown" } [5]=> array(2) { ["raw"]=> int(201) ["type"]=> string(7) "unknown" } [6]=> array(2) { ["raw"]=> int(287) ["type"]=> string(7) "unknown" } [7]=> array(2) { ["raw"]=> int(176) ["type"]=> string(7) "unknown" } [8]=> array(2) { ["raw"]=> int(206) ["type"]=> string(7) "unknown" } [9]=> array(2) { ["raw"]=> int(257) ["type"]=> string(7) "unknown" } [10]=> array(2) { ["raw"]=> int(141) ["type"]=> string(7) "unknown" } [11]=> array(2) { ["raw"]=> int(215) ["type"]=> string(7) "unknown" } [12]=> array(2) { ["raw"]=> int(136) ["type"]=> string(7) "unknown" } [13]=> array(2) { ["raw"]=> int(149) ["type"]=> string(7) "unknown" } [14]=> array(2) { ["raw"]=> int(137) ["type"]=> string(7) "unknown" } [15]=> array(2) { ["raw"]=> int(159) ["type"]=> string(7) "unknown" } }
[3]=> array(14) { [2]=> array(2) { ["raw"]=> int(128) ["type"]=> string(7) "unknown" } [3]=> array(2) { ["raw"]=> int(152) ["type"]=> string(7) "unknown" } [4]=> array(2) { ["raw"]=> int(111) ["type"]=> string(7) "unknown" } [5]=> array(2) { ["raw"]=> int(201) ["type"]=> string(7) "unknown" } [6]=> array(2) { ["raw"]=> int(287) ["type"]=> string(7) "unknown" } [7]=> array(2) { ["raw"]=> int(176) ["type"]=> string(7) "unknown" } [8]=> array(2) { ["raw"]=> int(206) ["type"]=> string(7) "unknown" } [9]=> array(2) { ["raw"]=> int(259) ["type"]=> string(7) "unknown" } [10]=> array(2) { ["raw"]=> int(141) ["type"]=> string(7) "unknown" } [11]=> array(2) { ["raw"]=> int(215) ["type"]=> string(7) "unknown" } [12]=> array(2) { ["raw"]=> int(136) ["type"]=> string(7) "unknown" } [13]=> array(2) { ["raw"]=> int(149) ["type"]=> string(7) "unknown" } [14]=> array(2) { ["raw"]=> int(137) ["type"]=> string(7) "unknown" } [15]=> array(2) { ["raw"]=> int(159) ["type"]=> string(7) "unknown" } } } }
{ [1]=> array(14) { [2]=> string(5) "Pd_10" [3]=> string(5) "Pd_15" [4]=> string(5) "Pd_16" [5]=> string(5) "Pd_25" [6]=> string(5) "Pd_32" [7]=> string(5) "Pd_35" [8]=> string(5) "Pd_50" [9]=> string(5) "Pd_57" [10]=> string(5) "Pd_63" [11]=> string(5) "Pd_70" [12]=> string(5) "Pd_78" [13]=> string(5) "Pd_85" [14]=> string(5) "Pd_90" [15]=> string(5) "Pd_93" } [2]=> array(15)
{ [1]=> string(8) "Allele_1" [2]=> string(3) "123" [3]=> string(3) "119" [4]=> string(3) "111" [5]=> string(3) "201" [6]=> string(3) "287" [7]=> string(3) "176" [8]=> string(3) "206" [9]=> string(3) "257" [10]=> string(3) "141" [11]=> string(3) "215" [12]=> string(3) "136" [13]=> string(3) "149" [14]=> string(3) "137" [15]=> string(3) "159" } [3]=> array(15)
{ [1]=> string(8) "Allele_2" [2]=> string(3) "128" [3]=> string(3) "152" [4]=> string(3) "111" [5]=> string(3) "201" [6]=> string(3) "287" [7]=> string(3) "176" [8]=> string(3) "206" [9]=> string(3) "259" [10]=> string(3) "141" [11]=> string(3) "215" [12]=> string(3) "136" [13]=> string(3) "149" [14]=> string(3) "137" [15]=> string(3) "159" } }
["cellsInfo"]=> array(2) { [2]=> array(14) { [2]=> array(2) { ["raw"]=> int(123) ["type"]=> string(7) "unknown" } [3]=> array(2) { ["raw"]=> int(119) ["type"]=> string(7) "unknown" } [4]=> array(2) { ["raw"]=> int(111) ["type"]=> string(7) "unknown" } [5]=> array(2) { ["raw"]=> int(201) ["type"]=> string(7) "unknown" } [6]=> array(2) { ["raw"]=> int(287) ["type"]=> string(7) "unknown" } [7]=> array(2) { ["raw"]=> int(176) ["type"]=> string(7) "unknown" } [8]=> array(2) { ["raw"]=> int(206) ["type"]=> string(7) "unknown" } [9]=> array(2) { ["raw"]=> int(257) ["type"]=> string(7) "unknown" } [10]=> array(2) { ["raw"]=> int(141) ["type"]=> string(7) "unknown" } [11]=> array(2) { ["raw"]=> int(215) ["type"]=> string(7) "unknown" } [12]=> array(2) { ["raw"]=> int(136) ["type"]=> string(7) "unknown" } [13]=> array(2) { ["raw"]=> int(149) ["type"]=> string(7) "unknown" } [14]=> array(2) { ["raw"]=> int(137) ["type"]=> string(7) "unknown" } [15]=> array(2) { ["raw"]=> int(159) ["type"]=> string(7) "unknown" } }
[3]=> array(14) { [2]=> array(2) { ["raw"]=> int(128) ["type"]=> string(7) "unknown" } [3]=> array(2) { ["raw"]=> int(152) ["type"]=> string(7) "unknown" } [4]=> array(2) { ["raw"]=> int(111) ["type"]=> string(7) "unknown" } [5]=> array(2) { ["raw"]=> int(201) ["type"]=> string(7) "unknown" } [6]=> array(2) { ["raw"]=> int(287) ["type"]=> string(7) "unknown" } [7]=> array(2) { ["raw"]=> int(176) ["type"]=> string(7) "unknown" } [8]=> array(2) { ["raw"]=> int(206) ["type"]=> string(7) "unknown" } [9]=> array(2) { ["raw"]=> int(259) ["type"]=> string(7) "unknown" } [10]=> array(2) { ["raw"]=> int(141) ["type"]=> string(7) "unknown" } [11]=> array(2) { ["raw"]=> int(215) ["type"]=> string(7) "unknown" } [12]=> array(2) { ["raw"]=> int(136) ["type"]=> string(7) "unknown" } [13]=> array(2) { ["raw"]=> int(149) ["type"]=> string(7) "unknown" } [14]=> array(2) { ["raw"]=> int(137) ["type"]=> string(7) "unknown" } [15]=> array(2) { ["raw"]=> int(159) ["type"]=> string(7) "unknown" } } } }
Cita:
Lo que yo quiero hacer al final es otra tabla mutidimensional que llamaré $$file_locus a partir de estos datos, y para ello hice lo siguiente:$genotype['cells'][1][2]; // Pd_10
$genotype['cells'][2][2]; // 123
$genotype['cells'][3][2]; // 128
$genotype['cells'][2][2]; // 123
$genotype['cells'][3][2]; // 128
Cita:
for($j=0;$j<count($genotype['cells']);$j++){
$i=2;
if ($genotype['cells'][2][$i] < $genotype['cells'][3][$i])
{
$locus_name=$genotype['cells'][1][$i];
$allele_1= $genotype['cells'][2][$i];
$allele_2= $genotype['cells'][3][$i] ;
$i++;
}
else { $locus_name=$genotype['cells'][1][$i];
$allele_1=$genotype['cells'][3][$i];
$allele_2=$genotype['cells'][2][$i];
$i++;
}
$file_locus = array ('locus_name'=>$locus_name,'allele_1'=>$allele_1,' allele_2'=>$allele_2);
}
$i=2;
if ($genotype['cells'][2][$i] < $genotype['cells'][3][$i])
{
$locus_name=$genotype['cells'][1][$i];
$allele_1= $genotype['cells'][2][$i];
$allele_2= $genotype['cells'][3][$i] ;
$i++;
}
else { $locus_name=$genotype['cells'][1][$i];
$allele_1=$genotype['cells'][3][$i];
$allele_2=$genotype['cells'][2][$i];
$i++;
}
$file_locus = array ('locus_name'=>$locus_name,'allele_1'=>$allele_1,' allele_2'=>$allele_2);
}
Pero mi var_dump ($file_locus) me da:
Cita:
Solo me recupera los datos del primer locus, y yo los quiero todos!!!, mi boucle no recorre la tabla; no logro saber en donde estoy fallando. Alguien podria ayudarme por favor?array(3) { ["locus_name"]=> string(5) "Pd_10" ["allele_1"]=> string(3) "123" ["allele_2"]=> string(3) "128" }
Muchas gracias desde ya