_siikais_ Posted May 15, 2008 Report Share Posted May 15, 2008 (edited) taatad mainiigais $masiivs ir sekojosh Array ( [katalogaid] => 2 [dati1] => kkas [dati2] => kkas2 [katalogs] => Array ( [0] => Array ( [id] => 1 [nosaukums] => kkaadsnosaukums [vertiba1] => 10 [vertiba2] => 15 ) [1] => Array ( [id] => 10 [nosaukums] => kkaadsnosaukums2 [vertiba1] => 11 [vertiba2] => 16 ) ) [special] => Array ( [id] => 1 [nosaukums] => kkaads ) ) katalogaid un datu veertiibas dabuut aaraa nau probleema foreach($masiivs $var=>$val) { $masiivsdati[$var]=$val; } taalaak lai dabuuti infu aara ano kataloga itkaa arii nau probleemas dabutu dabuu, bet gribeeju jautaat vai nau iespeejams kodu optimizeet ta alai stradaatu aatraak :D for($i=0;$i < $masiivsdati['katalogaid'];++$i) { foreach($masiivsdati['katalogs'][$i] as $var1=>$val1) { $masiivsdati[$var1]=$val1; } echo "<tr><td>".$masiivsdati['katalogs'][$i]['nosaukums']."</td><td>".$masiivsdati['katalogs'][$i]['vertiba1']."</td></tr>"; } Edited May 15, 2008 by _siikais_ Link to comment Share on other sites More sharing options...
andrisp Posted May 15, 2008 Report Share Posted May 15, 2008 foreach($masiivs['katalogs'] as $kataloga_aitems) { // } ? Link to comment Share on other sites More sharing options...
_siikais_ Posted May 15, 2008 Author Report Share Posted May 15, 2008 hmmm nesapratu tavu domu Link to comment Share on other sites More sharing options...
andrisp Posted May 15, 2008 Report Share Posted May 15, 2008 Drīzāk es laikam tevi nebūšu sapratis. Paskaidro, ko un kā tev tur īsti vajag izdarīt. Man galve mežģas mēģinot saprast. Link to comment Share on other sites More sharing options...
Kristabs Posted May 15, 2008 Report Share Posted May 15, 2008 (edited) Andris jau pateica atbildi - foreach($masiivsdati['katalogs'] as $var1=>$val1) { $val1[$var1]['id']=$id1; } Edited May 15, 2008 by Kristabs Link to comment Share on other sites More sharing options...
andrisp Posted May 15, 2008 Report Share Posted May 15, 2008 Kristabs, viņam tur iekš for vēl kaut kas dīvains: $i < $masiivsdati['katalogaid'] Link to comment Share on other sites More sharing options...
Kristabs Posted May 15, 2008 Report Share Posted May 15, 2008 Nu vinš nezināja kā daudzdimensionālam masīvam izdabūt tās vērtības ar pliku foreach, tāpēc tas for tur, man liekas. Link to comment Share on other sites More sharing options...
_siikais_ Posted May 15, 2008 Author Report Share Posted May 15, 2008 vnk peec esoshaas situaacijas peedeejais tags ieksh masiiva ievieto visu produktus un ar cikl apaliidziibu izvada no jaunizveidota amasiiva. bet esoshais variants diezgan leeni stradaa taapeec prasu vai ir iespeejams vinju kautkaa optimizeet... Link to comment Share on other sites More sharing options...
Recommended Posts