9 lines
257 B
PHP
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>";
|
||
|
}
|