UnixDevel Posted February 10, 2012 Report Share Posted February 10, 2012 Array ( [Entertainment] => 0.558299 [Science] => 6.0291E-6 [Sports] => 0.441695 )am urmatorul array ,cum fac sa extrag primul element cel cu Entertainment ,atentie stiu ca se face cu $a['Entertainment'] ,chestia este ca acel array este dinamic ,cum as putea sa il fac sa fie static ....adika mie din array-ul respectiv trebuie sa extrag intodeauna doar primele 2 intrari Entertainment si Science...dar care pot fi diferite in alte cazuri Quote Link to comment Share on other sites More sharing options...
BogdanNBV Posted February 10, 2012 Report Share Posted February 10, 2012 <?php$a = array('asdassda'=>2, 'caca'=>3, 'mue'=>33);$x = 1;foreach($a as $cheie=>$valoare){ if($x <=2) { echo $cheie."=>".$valoare."<br/>"; } $x++;}?>nu cred ca este cea mai buna metoda, sau cea mai rapida, dar functioneaza Quote Link to comment Share on other sites More sharing options...
UnixDevel Posted February 10, 2012 Author Report Share Posted February 10, 2012 daps , am facut altfel merci oricum , Quote Link to comment Share on other sites More sharing options...
BogdanNBV Posted February 10, 2012 Report Share Posted February 10, 2012 daca ai gasit alta modalitate, te rog, arata-mi, sa nu mor prost xD Quote Link to comment Share on other sites More sharing options...
qbert Posted February 10, 2012 Report Share Posted February 10, 2012 (edited) Ai putea sa faci si astfel <?$a = array('asdas'=>'34','dfsd3'=>'23');$b = array_keys($a);print $a[$b[0]];?> Edited June 23, 2012 by qbert Quote Link to comment Share on other sites More sharing options...