I'm trying to use a simple case statement to check the value of $item, which is returned as an array. The code returns the default case statement even though the array is equal to "iphones". Is there a simple way that I can get the value as a string?
This is the value of the array
object(stdClass)#209 (1) {
["item"]=>
string(7) "iphones"
}
and this is my code
class ItemController extends BaseController {
public function item ($item) {
$item = DB::table('Catagories')->where('item', $item)->first();
if (isset($item)) {
switch ($item) {
case "iphones":
echo "iphone!";
break;
case "phones":
echo "phones!";
break;
case "tablets":
echo "tablets!";
break;
default:
echo "string";
}
}
}
}