Welcome to the wonderful world of loose typing. In php, array_search defaults to nonstrict comparisons ("=="), but you can add a third parameter to force strict ("==="). You almost always want strict, though there are times when nonstrict is the correct operation.
check out the following:
$allcraftatts = array(0, 0, 0, 0, 0, 0, "Sharp Stone", "Sharp Stones", "stone", new stdClass(), "sharp", "hard", 0, 0, 0, 0, 0,0 ,0);
$testcopy=$allcraftatts;
$testsharp=array_search("sharp", $testcopy);
$testsharpStrict=array_search("sharp", $testcopy, true);
print_r(get_defined_vars());
if(0 == "sharp"){
echo "true for == \n";
}else{
echo "false == \n";
}
if(0 === "sharp"){
echo "true for === \n";
}else{
echo "false === \n";
}
and the output:
[testcopy] => Array
(
[0] => 0
[1] => 0
[2] => 0
[3] => 0
[4] => 0
[5] => 0
[6] => Sharp Stone
[7] => Sharp Stones
[8] => stone
[9] => stdClass Object
(
)
[10] => sharp
[11] => hard
[12] => 0
[13] => 0
[14] => 0
[15] => 0
[16] => 0
[17] => 0
[18] => 0
)
[testsharp] => 0
[testsharpStrict] => 10
)
true for ==
false ===