I am trying to sort array alphabetically using php sort function.
Array ( [0] => Open Sans [1] => Wellfleet [2] => Rambla [3] => Dosis [4] => Noto Sans [5] => Domine [6] => Signika Negative [7] => Arvo [8] => Neuton [9] => Rufina [10] => Tinos [11] => Podkova [12] => Magra [13] => Bitter [14] => Anton [15] => Libre Baskerville [16] => Tienne [17] => Roboto [18] => Ruda [19] => Merriweather [20] => Amaranth [21] => Playfair Display SC [22] => Cinzel Decorative [23] => Nobile [24] => Volkhov [25] => Nunito [26] => Merriweather Sans [27] => Stardos Stencil [28] => Bree Serif )
I have tried this one
$heading_fonts = sort($heading_fonts);
Eventually I am combining array to get same key and value.
$heading_fonts = array_combine($heading_fonts, $heading_fonts);
But giving me an error.
Warning: array_combine() expects parameter 1 to be array, boolean given in...
Any idea how can I sort an array to work?
The sort
function will sort your array in place and return a boolean value indicating its success. You should not assign its return value to the array. Use just:
sort($heading_fonts);