Blitz Posted February 16, 2006 Report Share Posted February 16, 2006 Piemeram ja es Java masivu uzrakstu ar roku: var content=new Array() content[0]='a' content[1]='ab' content[2]='n ' content[3]='.' content[4]='n' content[5]='fg' content[6]='jk' content[7]='gh' content[8]='fdf' tad viss straad t.i. funkcijas spej pieklut masiva elementiem. Bet ja es to izdaru ar php: $mape="./small/107"; $small_handle=opendir($mape); echo "var content=new Array()<br>"; $id=0; while ($file=readdir($small_handle)) { if ($file!=="." and $file!=="..") { $id++; $file_dat=explode("_",$file); $datums=$file_dat[2]; echo "content[$id]='as.'<br>"; } } closedir($small_handle); tad nestradaa. Izprintejot (echo) uz ekrana es neredzu nekadas atskiribas starp funkciju kas rakstita ar roku un to ko uztaisa php, bet viena strada, otra negrib... Kaa lai sito sataisa? Link to comment Share on other sites More sharing options...
Grey_Wolf Posted February 16, 2006 Report Share Posted February 16, 2006 (edited) nestraadaas ar :( ko tev tas <br> dara? paskaties surci.. vinja nebuus identiska... izmanto fprint() un <br> vietaa \n vai arii uliec ; ... edit: tev tur patreiz sanaak content[0]='a'<br>content[1]='ab'<br>..... utt. Edited February 16, 2006 by Grey_Wolf Link to comment Share on other sites More sharing options...
Blitz Posted February 16, 2006 Author Report Share Posted February 16, 2006 hei, liels paldies :) <br> apmainiju pret ; un viss aizgaja... Link to comment Share on other sites More sharing options...
bubu Posted February 16, 2006 Report Share Posted February 16, 2006 Java <> Javascript. Pie tam, masīvus (un līdzīgā veidā arī asociatīvos masīvus - mapus) javaskriptā ērti ir pierakstīt šādā veidā: var masiivs = ["a", "bbb", "", "casd", "peedeejais elements"]; (var protams ar enteriem aiz komatiem. Link to comment Share on other sites More sharing options...
Blitz Posted February 17, 2006 Author Report Share Posted February 17, 2006 ja pieraksta sada veidaa tad katra elementa key bus 0, 1, 2..n ?? Link to comment Share on other sites More sharing options...
bubu Posted February 17, 2006 Report Share Posted February 17, 2006 Jā. Ja vajag cita veida atslēgas (asociatīvo masīvu), tad var rakstīt šādi: var asoc_masiivs = { "atsleega1" : "value1", "atsleega2" : "value2" }; Atslēgas, protams, var būt ne tikai stringi, bet integeri vai pat veseli objekti. Un piekļūt tam protams var ar šādām abām sintaksēm: asoc_masiivs["atsleega1"] vai asoc_masiivs.atsleega1 Link to comment Share on other sites More sharing options...
Recommended Posts