lizard Posted November 27, 2006 Report Share Posted November 27, 2006 Kr4 rekur ira rinda nokuras janolasa ir pirmais vards aambo 2005-10-20 15:27:24 2006-11-25 21:14:37 bet izmantojot sho kodu es panaku ka man izvada aambo 2005-10-20 KAda veida atkratities no ta pielikuma un dabut roka tikai pirmo vardu kas irrindinja? <? $data = file("file.txt"); $xxx = $data[0]; $str = explode(" ", $xxx); Print("$str[0]"); ?> Link to comment Share on other sites More sharing options...
bubu Posted November 27, 2006 Report Share Posted November 27, 2006 Varbūt aambo un 2005-10-20 atdala nevis atstarpe, bet tab simbols \t ? Un kas tās par parversijām: "$str[0]" ? Link to comment Share on other sites More sharing options...
savejais Posted November 27, 2006 Report Share Posted November 27, 2006 bubu - masīvs, ko iztaisa explode(); Link to comment Share on other sites More sharing options...
Delfins Posted November 27, 2006 Report Share Posted November 27, 2006 (edited) Un kas tās par parversijām: "$str[0]" ? Pieļauju, ka `for fun` :) PS: lai būtu universāli preg_match('/^([^\s]+)/', $rinda,$vards ) Edited November 27, 2006 by Delfins Link to comment Share on other sites More sharing options...
lizard Posted November 27, 2006 Author Report Share Posted November 27, 2006 Nu a ka dabut tad to vardu ja nu tur ir kkads cits atdaloshais simbols? nevr kka uztaisit ka nogriezh no pirmas rindinjas tik talu kamer ir simbolu sakritiba burti vai cipari, un kad paradas atstarpe tur nogriezh nost? Link to comment Share on other sites More sharing options...
Delfins Posted November 27, 2006 Report Share Posted November 27, 2006 RTFC Link to comment Share on other sites More sharing options...
lizard Posted November 27, 2006 Author Report Share Posted November 27, 2006 (edited) Normala cilveku valoda nevar? Edited November 27, 2006 by lizard Link to comment Share on other sites More sharing options...
Delfins Posted November 27, 2006 Report Share Posted November 27, 2006 Man jāatkartojās? preg_match('/^([^\s]+)/', $rinda,$vards ) Link to comment Share on other sites More sharing options...
bubu Posted November 27, 2006 Report Share Posted November 27, 2006 ... un kad paradas atstarpe tur nogriezh nost? Tas ir jau tavā kodā uzrakstīts. Bet vai tu esi pārliecināts, ka tur ir atstarpe? Tb simbols " " (ASCII kods 32). Link to comment Share on other sites More sharing options...
blackhalt Posted November 27, 2006 Report Share Posted November 27, 2006 (edited) Nav tur `space` aambo 2005-10-20 15:27:24 2006-11-25 21:14:37 Loģiski, ka skripts izvada to $str[0] tā aambo 2005-10-20<---cut left --$str[0] -->15:27:24 2006-11-25 21:14:37 Pamēģini $str = explode("\t", $xxx); Edited November 27, 2006 by blackhalt Link to comment Share on other sites More sharing options...
bubu Posted November 27, 2006 Report Share Posted November 27, 2006 bh un kurš garantē, ka starp datubumu un laiku būs "\t" nevis " " ? Link to comment Share on other sites More sharing options...
blackhalt Posted November 27, 2006 Report Share Posted November 27, 2006 Neviens neko negarantē. Vajag atrast vismaz vienu kopīgo tajās rindās. Var izvilkt arī pēc "-" simbola. Link to comment Share on other sites More sharing options...
Val Posted November 27, 2006 Report Share Posted November 27, 2006 //ielasi pirmo rindu iekš $text $temp = explode('20', $text); echo trim($temp[0]); darbojas līdz 2099. gadam :D Link to comment Share on other sites More sharing options...
blackhalt Posted November 27, 2006 Report Share Posted November 27, 2006 Pēc Delfīna: <?php $data=file('file.txt'); $xxx=$data[0]; preg_match('/^([^\s]+)/',$xxx,$vards); echo $vards[0]; ?> Link to comment Share on other sites More sharing options...
Recommended Posts