>How do I delete a specific time out of the array or 
> how do I delete 
> a range of times out of the array?  I would like to be able to delete 
> 12:05:00 but if I want, delete a range like 12:05:00 to 
> 12:10:00.

Here's some code.

Kirk

function remove_array_values($valuesToRemove, $array)
{
  if (is_array($array))
  {
    // convert the input to an array, so only one logic block is needed
below
    if (!is_array($valuesToRemove))
    {
      $valuesToRemove = (array) $valuesToRemove;
    }

    foreach ($valuesToRemove as $value)
    {
      $match = true;
      // use the do...while to get multiple occurrences of the value to
delete
      do
      {
        // array_search returns 'null' or 'false' if the value is not found,
        // and the index if the value is found, so any number indicates a
match
        $index = array_search($value, $array);
        if (is_numeric($index))
        {
          unset($array[$index]);
        }
        else
        {
          $match = false;
        }
      }
      while ($match);
    }
    // re-index the array
    return array_values($array);
  }
  else
  {
    // return false on bad input
    return false;
  }
}

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to