. I have two array
First One
Array
(
[0] => Array
(
[date] => 2012-01-10
[result] => 65
Use array_merge() to combine the arrays, and then use sort to sort() to sort them, very simple. Would you like an example?
This should sort it for you:
function dateSort($a,$b){
$dateA = strtotime($a['date']);
$dateB = strtotime($b['date']);
return ($dateA-$dateB);
}
$arrayOne = array(
array(
'date' => '2012-01-10',
'result ' => 65,
'name' => 'Les océans'
),
array(
'date' => '2012-01-11',
'result ' => 75,
'name' => 'Les mers'
),
array(
'date' => '2012-01-13',
'result ' => 66,
'name' => 'Les continents',
'type' => 'Scores'
)
);
$arrayTwo = array(
array(
'date' => '2012-01-12',
'result ' => 60,
'name' => 'Step#1',
'type' => 'Summary'
)
);
// Merge the arrays
$combinedArray = array_merge($arrayOne,$arrayTwo);
// Sort the array using the call back function
usort($combinedArray, 'dateSort');