sfx Posted January 15, 2004 Report Share Posted January 15, 2004 Man ir logfails kuraa ir sekojosha rinda: 06.01.0413:53:12 1 13 00:00:047800201 2 un man vinju vaig sadalii shaadi: 06.01.04 | 13:53:12 | 1 | 13 | 00:00:04 | 7800201 | 2 ja buutu starpaa vienkaarshi simboli kaa '.' tad izmantotu shaadu variantu: $contest = file("log.txt"); while ($val=each($contest)){ $tmp1 = explode(".",$val[1]); print("$tmp1[0].$tmp1[1].$tmp1[2]"); } BET KO IZMANTOT ja attdaliishanas simboli ir dazhaadi ('.' ':' ' ') un kaa attdaliit ja starp skaitljiem nav atdaliisghanas ziimes? Link to comment Share on other sites More sharing options...
Kaklz Posted January 15, 2004 Report Share Posted January 15, 2004 BET KO IZMANTOT ja attdaliishanas simboli ir dazhaadi ('.' ':' ' ')apskatīt visus gadījumus - vispirms atdalīt tos, kas ar komatu, peec tam tos, kas ar punktu, utt. vari vienkaarshi aizvietot visus citus pret vienu konkreetu ar kaut vai str_replace. teiksim ja tev atdaliitaaji var buut , . : , tad , un . aizvieto ar : un peec tam atdaliishanu veic tikai ar : paliidziibu .. un kaa attdaliit ja starp skaitljiem nav atdaliisghanas ziimes? tikai un vienīgi ar rokām. Link to comment Share on other sites More sharing options...
hu_ha Posted January 15, 2004 Report Share Posted January 15, 2004 nu te var izmantot funkciju explode() panjem sadali peec punktiem un peec tam to pashu peec kola. veel viens variants njemt substringu - tipa pirmie divi simboli, tad atkal no 3 liidz 4 utt. Link to comment Share on other sites More sharing options...
Venom Posted January 15, 2004 Report Share Posted January 15, 2004 preg_split() sscanf() explode pēc " " pēc tam atsevišķiem elementiem explode pēc ":" pēc tam atsevišķiem elementiem explode pēc "." un visu sagāst citā masīvā pēc kārtas Link to comment Share on other sites More sharing options...
sfx Posted January 15, 2004 Author Report Share Posted January 15, 2004 Liels paldies! Sapratu, gan jau tikshu krastaa! :) Link to comment Share on other sites More sharing options...
Roze Posted January 17, 2004 Report Share Posted January 17, 2004 Repleisot visus splitojamos (atdalaamos) simbolus par vienu (piem . , uz | ) un tad explode.. Link to comment Share on other sites More sharing options...
Recommended Posts