Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $myarray = array(1,0.334,-0.334,-1);
- //create a copy and sort
- $myarray_copy = $myarray;
- rsort($myarray_copy);
- //reverses key and values
- $myarray_copy = array_flip($myarray_copy);
- //create result by using keys from sorted values + 1
- foreach($myarray as $val)
- $myarray2[] = ($myarray_copy[$val]+1);
- //print final array
- print_r($myarray2);
- print_r($myarray);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement