Array:
Array
(
[0] => Array
(
[Create_date] => 2017-10-17
[Description] => Cash
[Debit] =>
[Credit] => 27612
[Type] => Credit
)
[1] => Array
(
[Create_date] => 2017-10-17
[Description] => Invoice ID = 22
[Debit] => 27612
[Credit] =>
[Type] => Debit
)
[2] => Array
(
[Create_date] => 2017-10-17
[Description] => Invoice ID = 20
[Debit] => 1008
[Credit] =>
[Type] => Debit
)
[3] => Array
(
[Create_date] => 2017-10-17
[Description] => Invoice ID = 19
[Debit] => 1168.2
[Credit] =>
[Type] => Debit
)
[4] => Array
(
[Create_date] => 2017-10-17
[Description] => Invoice ID = 18
[Debit] => 276.12
[Credit] =>
[Type] => Debit
)
)
PHP:
function date_compare($a, $b)
{
$t1 = strtotime($a['Create_date']);
$t2 = strtotime($b['Create_date']);
return $t1 - $t2;
}
usort($data['Ledgers'], 'date_compare');
Expected Output:
[0] => Array
(
[Create_date] => 2017-10-17
[Description] => Invoice ID = 22
[Debit] => 27612
[Credit] =>
[Type] => Debit
)
[1] => Array
(
[Create_date] => 2017-10-17
[Description] => Invoice ID = 20
[Debit] => 1008
[Credit] =>
[Type] => Debit
)
[2] => Array
(
[Create_date] => 2017-10-17
[Description] => Invoice ID = 19
[Debit] => 1168.2
[Credit] =>
[Type] => Debit
)
[3] => Array
(
[Create_date] => 2017-10-17
[Description] => Invoice ID = 18
[Debit] => 276.12
[Credit] =>
[Type] => Debit
)
[4] => Array
(
[Create_date] => 2017-10-17
[Description] => Cash
[Debit] =>
[Credit] => 27612
[Type] => Credit
)
After executing function I got this array. Now I want to order array by date and character. I gave my expected output anyone can please Help me How can I achieve my expected output? Sorry for my grammatical mistakes. Please edit this question for readability so it may help others.