coldfission Posted September 9, 2008 Share Posted September 9, 2008 if ($key = array_search($sku,$inventory_sku)) { $inventory_q[$key] = $inventory_q[$key] + $quantity; } else { $inventory_q[$inv_count] = $quantity; $inventory_sku[$inv_count] = $sku; $inv_count++; } What if the $key = 0? That tells the IF statement that it is false and, in my case, will insert a new record when i don't want it to. How do i solve this problem? thanks Quote Link to comment https://forums.phpfreaks.com/topic/123503-array_search-returns-zero-and-thinks-false/ Share on other sites More sharing options...
sasa Posted September 9, 2008 Share Posted September 9, 2008 if (($key = array_search($sku,$inventory_sku))!==false) Quote Link to comment https://forums.phpfreaks.com/topic/123503-array_search-returns-zero-and-thinks-false/#findComment-637830 Share on other sites More sharing options...
coldfission Posted September 10, 2008 Author Share Posted September 10, 2008 thanks that did it Quote Link to comment https://forums.phpfreaks.com/topic/123503-array_search-returns-zero-and-thinks-false/#findComment-638366 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.