blondine Posted May 27, 2010 Report Share Posted May 27, 2010 nevaru saprast kaa labak un sapratigak sortet.. pec faila nosaukuma, kas satur timestamp, vai failaa saglabato datumu.. foreach (glob($this->dir."*.txt") as $path) { $history = fopen($path, "rb+"); ... } Quote Link to comment Share on other sites More sharing options...
briedis Posted May 27, 2010 Report Share Posted May 27, 2010 (edited) Hmm, nevaru izštukot, vakarā vārīt pelemeņus vai makaronus... Nu tak sortē kā vēlies :) Edited May 27, 2010 by briedis Quote Link to comment Share on other sites More sharing options...
briedis Posted May 27, 2010 Report Share Posted May 27, 2010 RTFM Quote Link to comment Share on other sites More sharing options...
rATRIJS Posted May 27, 2010 Report Share Posted May 27, 2010 Hmm, nevaru izštukot, vakarā vārīt pelemeņus vai makaronus... Tak pelmenjus protams. No plikiem makaroniem paeest nevar a pelmenjos klaat veel galja!!! Quote Link to comment Share on other sites More sharing options...
blondine Posted May 27, 2010 Author Report Share Posted May 27, 2010 foreach (glob($this->dir."*.txt") as $path) { $history = fopen($path, "rb+"); arsort ($path); ... if ($year < date($date)) { print '<h3>'.date("Y", $date).' .gads</h3>'; } $year = date($date); arsort() expects parameter 1 to be array, string given.. var_dump($path); string(39) "./history/history_01012007-17.13.18.txt" 2007 .gads string(39) "./history/history_03032006-17.10.27.txt" string(39) "./history/history_07072007-17.13.46.txt" 2007 .gads string(39) "./history/history_10102006-17.12.36.txt" string(39) "./history/history_12022006-17.10.50.txt" 2006 .gads Quote Link to comment Share on other sites More sharing options...
briedis Posted May 27, 2010 Report Share Posted May 27, 2010 Nu jā, bet ko tad tu gaidīji? asort ņem pretī masīvu, ko sortēt... nevis vienkārši stringu.. Quote Link to comment Share on other sites More sharing options...
briedis Posted May 27, 2010 Report Share Posted May 27, 2010 meginaju ari apgraizit stringu un usort($path,"strnatcmp"); The argument should be an array.. Hmm, tev tiešām tik ļoti interesē programmēšana? :) Tu zini kas ir masīvs? Ja tu zini, tad tev jāsaprot, ka tā funkcija grbi, lai tu viņai dod masīvu, nevis stringu! Quote Link to comment Share on other sites More sharing options...
mefisto Posted May 27, 2010 Report Share Posted May 27, 2010 Labāk makaronus , un pēc tam apcep ar sieru un dzīviem tomātiem. Kā jau iepriekš vienā postā rakstīju : problēmas kuras tiek "risinātas" dikt' nesakrīt ar zināšanu līmeni. Nu tākā tu kaut kur augstāk izmantoji funkciju glob(), tad kāpēc tu neiemācies to funkciju lietot ? Quote Link to comment Share on other sites More sharing options...
blondine Posted May 27, 2010 Author Report Share Posted May 27, 2010 (edited) man vairak intersee nevis filemtime kartosana, bet gan filename saturosais date ka string jeb failaa saglabtais timestamp.. jo tas tiek padots atseviski: $_POST['month'],$_POST['day'],$_POST['year']); un sanak, lai kaa ari kartotu pec filemtime , failaa saglabatais timestamp bus jauktaa kartiba..vai es kludos?! Edited May 27, 2010 by blondine Quote Link to comment Share on other sites More sharing options...
blondine Posted May 28, 2010 Author Report Share Posted May 28, 2010 ka veiksmigak sakartot sadu masivu pec indeksa [0].. array(4) { [0]=>"1167664398" [1]=>"aaa " [2]=>"bbb" [3]=>"ccc" } array(4) { [0]=>"1141398627" [1]=>"aaa" [2]=>"bbb" [3]=>"ccc" } utt. Quote Link to comment Share on other sites More sharing options...
codez Posted May 28, 2010 Report Share Posted May 28, 2010 function test($a1,$a2){return $a1[0]>$a2[0];} usort($a,'test'); no PHP 5.3.0 usort($a,function($a1,$a2){return $a1[0]>$a2[0];}); Quote Link to comment Share on other sites More sharing options...
blondine Posted May 28, 2010 Author Report Share Posted May 28, 2010 nestados prieksaa ja $a =n; ? Quote Link to comment Share on other sites More sharing options...
codez Posted May 28, 2010 Report Share Posted May 28, 2010 (edited) $a = array( array("0"=>124,"1"=>"aaa"), array("0"=>122,"1"=>"aaa"), array("0"=>123,"1"=>"aaa") ); Edited May 28, 2010 by codez Quote Link to comment Share on other sites More sharing options...
blondine Posted May 28, 2010 Author Report Share Posted May 28, 2010 (edited) sanaca kas tads, visticamak to visu var daudz vnk apstradat..: priekslikumi - idejas. kods Edited May 28, 2010 by blondine Quote Link to comment Share on other sites More sharing options...
blondine Posted May 29, 2010 Author Report Share Posted May 29, 2010 (edited) $date= mktime(date("H"), date("i"), date("s"), $_POST['month'],$_POST['day'],$_POST['year']); neskatoties uz visu sort($arr) - rezultata nesakarto pareizi: 2008.02.05-ddd (1202204842) 2007.02.27-ccc (1172569584) 2006.03.07-bbb .. 2006.06.11-eee .. 2005.06.28-aaa .. 2006.08.08-fff .. 2005.09.01-eee .. nevar saprast pec kada principa sakarto..bet izskatas, ka sakarto pec menesiem (mistiskaa veida). Edited May 29, 2010 by blondine Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.