diff --git a/modules/saml/www/sp/metadata.php b/modules/saml/www/sp/metadata.php
index df6d1f0b412953d9f5258367bd57c34e27c43edb..16b60086352dce43ad6244c9dcaafeedb1f8e931 100644
--- a/modules/saml/www/sp/metadata.php
+++ b/modules/saml/www/sp/metadata.php
@@ -66,7 +66,7 @@ if (array_key_exists('output', $_REQUEST) && $_REQUEST['output'] == 'xhtml') {
 
 	$t->data['header'] = 'saml20-sp';
 	$t->data['metadata'] = htmlspecialchars($xml);
-	$t->data['metadataflat'] = var_export($entityId, TRUE) . ' => ' . var_export($metaArray20, TRUE) . ',';
+	$t->data['metadataflat'] = '$metadata[' . var_export($entityId, TRUE) . '] = ' . var_export($metaArray20, TRUE) . ';';
 	$t->data['metaurl'] = $source->getMetadataURL();
 
 	$t->data['idpsend'] = array();
diff --git a/www/saml2/idp/metadata.php b/www/saml2/idp/metadata.php
index 2fb5d491d2b0d3968a7ebd6a3562ed675e6f073d..3f172bd67dac403735faae69851c83aae2e628b9 100644
--- a/www/saml2/idp/metadata.php
+++ b/www/saml2/idp/metadata.php
@@ -66,7 +66,7 @@ try {
 	}
 
 
-	$metaflat = var_export($idpentityid, TRUE) . ' => ' . var_export($metaArray, TRUE) . ',';
+	$metaflat = '$metadata[' . var_export($idpentityid, TRUE) . '] = ' . var_export($metaArray, TRUE) . ';';
 
 	$metaArray['certData'] = $certInfo['certData'];
 	$metaBuilder = new SimpleSAML_Metadata_SAMLBuilder($idpentityid);
diff --git a/www/saml2/sp/metadata.php b/www/saml2/sp/metadata.php
index ba3c13267f520685a66921ab960bacb16c994702..8ee0faf9546fe0b950e83197408539a32792fcb3 100644
--- a/www/saml2/sp/metadata.php
+++ b/www/saml2/sp/metadata.php
@@ -49,7 +49,7 @@ try {
 		$metaArray['certData'] = $certInfo['certData'];
 	}
 
-	$metaflat = var_export($spentityid, TRUE) . ' => ' . var_export($metaArray, TRUE) . ',';
+	$metaflat = '$metadata[' . var_export($spentityid, TRUE) . '] = ' . var_export($metaArray, TRUE) . ';';
 
 	$metaBuilder = new SimpleSAML_Metadata_SAMLBuilder($spentityid);
 	$metaBuilder->addMetadataSP20($metaArray);