Sorting time in an array with foreach in PHP
<pre><code>$result = array("test" =&gt; "21:00", "test" =&gt; "11:00", "test" =&gt; "19:00", "test" =&gt; "04:00");
$sortedArray = array();
foreach ($result as $test =&gt; $mealTime) {
    if () {
        array_push($sortedArray, $mealTime);
    }
}
</code></pre>

<p>This is what I have done right now. I would like to make a new array out of the <code>$result</code> array. And in this new array I would like it to be sorted out from the meal times. </p>

<p>As you see in the current <code>$result array</code> it is unsorted as 04:00 which is in the end of the array is lower than 21:00.</p>

<p>So the correct array would be: 04:00, 11:00, 19:00, 21:00 (in the above example).</p>

<p>How can I do this? The above code is just an example of what I tried and then got stuck at writing a <code>if</code> statement to it..</p>
