Cofem/lib/script_data.php

9 lines
257 B
PHP
Raw Normal View History

2024-02-05 21:21:04 +01:00
<?php
function generateScriptData($input) :string
{
// Convert PHP array to JSON string
$jsonString = json_encode($input);
// Output JavaScript code with the JSON string
return "<script>let pageData = JSON.parse('$jsonString');</script>";
}