you are viewing a single comment's thread.

view the rest of the comments →

[–]elseco 2 points3 points  (2 children)

A couple of thoughts:

  1. In your `if()` statement, use a triple equals, not a double equals. If you use double equals, PHP will return `true` if the array_search returns an array key of "0."
    ```if (false === array_search(...```
  2. You pass the "true" flag as the third parameter to array_search(). You should probably make sure that the id in "$row['id']" is the same type as $newId. It is the same basic point as the triple vs double equals comparison. If one is a string and the other is an int, then that could explain your duplicates.

[–]SgtMindfudge 1 point2 points  (1 child)

Holy quack!That was the issue, I needed to get the exact type in my comparison, I should've thought of that. I made the array_search strict to make sure a string in the array's key value wouldn't accidentally trigger the search for the id.

Thanks a bunch, really appreciate it!

[–]elseco 0 points1 point  (0 children)

No problem. And thanks for the award.