Jump to content
php.lv forumi

txt faila sortesana..


blondine

Recommended Posts

	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

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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 ?

Link to comment
Share on other sites

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 by blondine
Link to comment
Share on other sites

$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 by blondine
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...