Create Empty Object In Laravel

create blank object

#Many of ways is to create a blank object in laravel. When a value or object is empty then set blank or empty object in your output.

#Type 1 :-

$object = (object)array();

Output:- “object”: {}

#Type 2

$object = (object)[];
Output:- "object": {}

#Type 3 :-

$object = json_decode('{}');
Output:- "object": {}

#Type 4 :-

$object = null;
Output:- "object": null

Leave a Comment

Your email address will not be published. Required fields are marked *