Jump to content

array_search returns zero and thinks false


coldfission

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.