I’m using a rather rudimentary process of checking an array of urls vs my database of urls which are unique. $sql = "INSERT INTO linkz (url, last_visited) VALUES ('".$url."', NOW())"; I then unset the value of the array if it errors via:
if (!mysql_query($sql,$con)){
unset($grabbedURL[$key]);
}
This worked fine and dandy until I tried to pass the array through an $i++ for statement to iterate across all the values in the array. The problem I’m running in to is that when you unset the values from the array, you lose the offset in the array. So if [2] was removed, I get an undefined offset error post-processing. Should I just set an if statement to check if the offset is null? Is there a better way I should be doing this?
Thanks in advance!
Tre
It seems what you want to do is shift the indices back. Here’s a nice little article about this:
http://xmouse.ithium.net/2004/removing-values-from-a-php-array
Basically what you want to do is this: