php - Remove before echoing -
say have list this hello1 hello2 hello3 hello4 goodbye hello6 hello7 hello8 how can remove goodbye , print everything else besides goodbye? use unset , array_search this: $array = array('hello1','hello2','hello3','hello4','goodbye','hello6','hello7','hello8'); if(($key = array_search('goodbye', $array)) !== false) unset($array[$key]); this 2 things in 1 if statement: if assigned value of $key (the return value of array_search ) truthy, proceed , use index, otherwise, don't anything. necessary because if return value of array_search false , resulting $array[false] not intended behavior @ all.