When I gave this command echo $ user-> gt; cards appeared:
[{"id":10,"id_user":2,"id_card":"11222","created_at":null,"updated_at":null,"deleted_at":null}]
How to access the 'deleted_at' property of this object?
When I gave this command echo $ user-> gt; cards appeared:
[{"id":10,"id_user":2,"id_card":"11222","created_at":null,"updated_at":null,"deleted_at":null}]
How to access the 'deleted_at' property of this object?
When using json_decode, the string generates an object within an array. Here's how to proceed:
$str = '[{"id":10,"id_user":2,"id_card":"11222","created_at":null,"updated_at":null,"deleted_at":null}]';
$arr = json_decode($str);
$deleted_at = $arr[0]->deleted_at;
if (is_null($deleted_at)) {
echo 'Nulo';
} else {
echo 'Não nulo';
}
This will display "Null".