PHP insenstivite multisort

I'm using this function to sort my multidimensional array:

function array_sort_by_column(&$arr, $col, $dir = SORT_ASC) {
    $sort_col = array();
    foreach ($arr as $key=> $row) {
        $sort_col[$key] = $row[$col];
    }

    array_multisort($sort_col, $dir, $arr);
}

and then call it for example like this:

array_sort_by_column($items, 'name', SORT_DESC);

Now the sorting in general works, but there is one problem: It's case sensitive, so if I have a list of :

  • apple
  • orange
  • Pear
  • Banana

the banana wouldn't come to the second place of the list (or array), but instead to the first place, so first, there are the words with starting capital letters, and then the other ones.

So expected behaviour of the list above would be

  • apple
  • Banana
  • orange
  • Pear

Actual output is:

  • Banana
  • Pear
  • apple
  • orange

What can I change to do this not case sensitive?

This should do:

array_multisort($sort_col, $dir|SORT_NATURAL|SORT_FLAG_CASE, $arr);

From php docs:

SORT_FLAG_CASE - can be combined (bitwise OR) with SORT_STRING or SORT_NATURAL to sort strings case-insensitively