I am trying to create a php file that sends some information to the recipient's email address . My code works but , it only sends the $data and not the $key as well .

I want this php script to make the following output :

Firstname : Theodore (for example)
Lastname : Zerbas (for examle)

Is there somebody to help me out ? thank you for your time.

$firstname = $_POST['fname'];
$lastname  = $_POST['lname'];

$to = "example@example.com";

$message = array("name"=>$firstname,"lastname:"=>$lastname);

foreach($message as $key=>$data)

	echo "Your message has been sent successfully";
 {echo " Something went wrong";}