Your array is rather strange: why not just use key as the index, and value as ... the value?
It would not be much easier if your array were declared like this:
$array = array( 1 => 'Awaiting for Confirmation', 2 => 'Asssigned', 3 => 'In Progress', 4 => 'Completed', 5 => 'Mark As Spam', );
This will allow you to use your key values โโas indexes to access the array ...
And you can use functions to search by values, such as array_search() :
$indexCompleted = array_search('Completed', $array); unset($array[$indexCompleted]); $indexSpam = array_search('Mark As Spam', $array); unset($array[$indexSpam]); var_dump($array);
Easier than with your array, no?
Instead, with your array that looks like this:
$array = array( array('key' => 1, 'value' => 'Awaiting for Confirmation'), array('key' => 2, 'value' => 'Asssigned'), array('key' => 3, 'value' => 'In Progress'), array('key' => 4, 'value' => 'Completed'), array('key' => 5, 'value' => 'Mark As Spam'), );
You will need to iterate over all the elements, analyze the value and reset the necessary elements:
foreach ($array as $index => $data) { if ($data['value'] == 'Completed' || $data['value'] == 'Mark As Spam') { unset($array[$index]); } } var_dump($array);
Even if it is doable, it is not so simple ... and I insist: can you change the format of your array to work with a simpler key / value system?