-1

I have p.e. the next array and I must sort it and then outputs the result using var_export().

 $array = [
     'hello',
     'internet',
     'people'
 ];

The code should follow 2 criteria (the 2nd one is used in case the first results in a draw):

  • 1st criterion is the number of vowels (aeiou) in the string. A string with more vowels should come first.
  • 2nd criterion is the alphabetical order of the reversed string (hello -> olleh). Order it from "a" to "z". (ASCII sort, just like the one implemented by strcmp())

With the test data $array presented above the expected result would be:

 array('people', 'internet', 'hello')

Any idea?

1 Answers1

0

You can view your desired output by "array_reverse" function.

<?php
  $array = [
   'hello',
   'internet',
   'people'
  ];
  $newArray = array_reverse($array,true);
  var_export($newArray);
?>