Jump to content
php.lv forumi

par masiiviem (atkal :D)


_siikais_

Recommended Posts

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 by _siikais_
Link to comment
Share on other sites

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

×
×
  • Create New...