php - Removing elements from an array whose value matches a specified string -


i have array looks this:

 array ( [0] => vice president [1] =>   [2] => other [3] => treasurer ) 

and want delete value other in value.

i try use array_filter filter word, array_filter delete empty values, too.

i want result this:

 array ( [0] => vice president [1] =>   [2] => treasurer ) 

this php filter code:

function filter($element) {   $bad_words = array('other');      list($name, $extension) = explode(".", $element);   if(in_array($name, $bad_words))     return;    return $element; }  $sport_level_new_arr = array_filter($sport_level_name_arr, "filter");  $sport_level_new_arr = array_values($sport_level_new_arr);  $sport_level_name = serialize($sport_level_new_arr); 

can use method filter word?

foreach($sport_level_name_arr $key => $value) {    if(in_array($value, $bad_words)) {       unset($sport_level_name_arr[$key])   }  } 

Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -