put class in array php code example Example: add object in array php Click to copy$myArray = array("name" => "my name"); echo json_encode($myArray);