Hello forums !!
Case:
I had the array as:
$array = array(1 => array('key1' => 'xxx', 'status' => 'Y'), 2 => array('key1' => 'yyy', 'status' => 'N'), 3 => array('key1' => 'zzz', 'status' => 'N')...);
I would like to find the next and previous key in the array according to the status. ie
function getNextKey(){
//should return the 2 as 1 key has status Y (Yes)
// if 1 key has status 'N' then it should return 1 key
// ie it should be the next to the last key with status Y
}
function getCurrentKey(){
// should return 1
// if 2 key too had status 'Y' then it should return 2
// ie it should be the last key with status Y.
}
function getPrevkey(){
// should return null
// if 2 key too had status 'Y' then it should return 1
// ie it should be the prev to the last key with status Y
}
Additionally:
Status key with status = Y means that key 's operation has been performed.
so if key 1 has status Y then next would be obviously 2 to be performed next..
For getNextKey, it should be the next to the last key with status Y
for getPrevkey, it should be the prev to the last key with status Y
for getCurrentKey, it should be the last key with status Y.
How to accomplish this type of array manipulation??
Thanks in advance for the valueable help.