
I am trying to integrate this logic in my script but I can’t really get a good grab around this or find any search function that will perform this..
I am trying to make a code snippet that arranges an array in the order of what the value of $onca is. $onca is a randomly changing variable and its possible values consist of the elements in an array $oncMail. Everytime $onca changes to a new value I would like the array to sort it self out by taking the new variable’s location in the array and swapping it with the old value’s position so that the new value becomes the 1st in the array and the old one goes to the position of index in the array of old value. To make more sense I have attached a picture of the logic process..
Whenever the value of
$oncachanges, usearray_searchto find the corresponding element and swap it with the first one:See it in action.