$tagtodelete = urldecode($_POST['tagdelete']); $formdetails['taglist'] = explode(',', $formdetails['taglist']); unset($formdetails['taglist'][array_search($tagtodelete, $formdetails['taglist'])]); $formdetails['taglist'] = implode(',', array_values($formdetails['taglist']));