I have this array, I want to remove the empty values

////
Array ( [55119901] => 3 [55219902] => 3 [17110405] => 1 [] => 3)
////

I want to delete the empty key/value

////
[] =>3
////

So I will end up with this array as a reusult

////
Array ( [55119901] => 3 [55219902] => 3 [17110405] => 1)
////

What is the array function for that task, I can't figure it out.

Thanks in advance for your help

    I don't know if a key can be empty. Even if you create array without explicit keys, they are created using integers.
    But if it could, my algorithm would be:
    - find all the keys in an array ([man]array_keys()[/man])
    - for each key check if it's empty ([man]foreach[/man})
    - if it's empty, [man]unset[/man] that element - that's when it comes to some trouble - how to unset it when the key is already empty.

      it is perfectly legal to have an empty array key. just use [man]unset[/man] as you would any other array key:

      $array = array(
      	'1' => 'one',
      	'2' => 'two',
      	'' => 'nothing',
      	'3' => 'three',
      	'4'  => 'four'
      );
      
      unset($array['']);
      print_r($array);
      
        Write a Reply...