stylehub/lib/script_data.php
2024-02-05 21:21:04 +01:00

9 lines
257 B
PHP

<?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>";
}