Ascending order of text file using php

Hello,
i am ascending order of text file.
for example
i make text file whose name saved.txt
ramzan:12 - 12 - 2018:12
ramzan:15 - 03 - 2018:13
ramzan:12 - 05 - 2018:14
ramzan:12 - 10 - 2018:15
i show result ascending order
result show
ramzan:15 - 03 - 2018:13
ramzan:12 - 05 - 2018:14
ramzan:12 - 10 - 2018:15
ramzan:12 - 12 - 2018:12

how can this

Use file() to read the lines of the file into an array. Use array_map() and a user written call-back function to parse/break each line into an array of appropriate fields. Use usort() and another user written call-back function to sort the data on the appropriate field.

send complete code
thanks advance

We are not a code on demand service. A member has told you what to do. It is now up to you to make an attempt at it.

send complete code

Send payment
Then I can send complete code

:smile:

1 Like

$file=" saved.txt";
$doc=file_get_contents($file);
$line=explode("\n",$doc);
foreach($line as $newline){
$num = explode(":", $newline);
sort($num);
$sex = $num[1];
$string = str_replace(’ ', ‘’, $sex);
echo “…
”;
echo $string . “
”;
$d1=strtotime($string);
echo $d1 . “
”;
echo date(“d-m-Y”, $d1) . “
”;
}

Sponsor our Newsletter | Privacy Policy | Terms of Service