array_ filter is pretty much what I need... but it retains the key values. so you may end up with a key set like 0, 3, 5, 6.

How do i reset this? so it doesn't retain the keys...

I swear there is an easy way to do this i can't for the life of me find...

    This should do the trick:

    $newArray = array_values(array_filter($array, 'callback_function'));
    

      I don't get how that would work... (following example taken from PHP docs)

      $entry = array(
                   0 => 'foo',
                   1 => false,
                   2 => -1,
                   3 => null,
                   4 => ''
                );
      
      print_r(array_filter($entry));
      

      outputs;

      Array
      (
          [0] => foo
          [2] => -1
      )
      

      and I'm trying to achieve...

      Array
      (
          [0] => foo
          [1] => -1
      )
      

      I thought there was a function to reset the array keys or something? I can't find it.

      I'm close to just looping through and doing it manually...

        I thought there was a function to reset the array keys or something? I can't find it.

        [man]array_values/man.

          Write a Reply...