andain Posted November 11, 2005 Report Share Posted November 11, 2005 nezinaju uz ko tieshi serchot tape uztaisiju jaunu topiku. lieta tada ka mape stav .tar faili ar nosaukumiem, piem, xxx-0511111010-yyy.tar gribeju uzzinat vai ar php palidzibu var sadalit sho faila nosaukumu pa kkadiem mainigiem, lai weba varetu salikt jamos pa tabulam. piemeram: nosaukums: xxx datums: 05-11-11 laiks: 10:10 vel kkas - yyy ceru ka sapratat manu liiko domu gajienu :) Link to comment Share on other sites More sharing options...
bubu Posted November 11, 2005 Report Share Posted November 11, 2005 (edited) if (preg_match('#^([^-]+)-(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)-([^.]+).*$#', $fileName, $m)) { echo 'Nosaukums: ', $m[1], "\n"; echo 'Datums: ', $m[2], '-', $m[3], '-', $m[4], "\n"; echo 'Laiks: ', $m[5], ':', $m[6], "\n"; echo 'Vēl kauktas: ', $m[7], "\n"; } else { echo 'fileName Nesakrīt ar formātu!', "\n"; } Edited November 11, 2005 by bubu Link to comment Share on other sites More sharing options...
[Ya] Posted November 11, 2005 Report Share Posted November 11, 2005 tas tak i vienkārši .. $file="xxx-0511111010-yyy.tar"; $sagr=spliti("-",$file); $xxx=$sagr[0]; $yyy=$sagr[2]; for($x=0;$x<5;$x++) { $dat[]=substr($sagr[1],$x*2,2); } $dat[0] // 05 (gads) $dat[1] // 11 (menesis) $dat[2] // 11 (datums) $dat[3] // 10 (stundas) $dat[4] // 10 (minutes) Link to comment Share on other sites More sharing options...
Recommended Posts