How to pass an array from .php file to .html file ?
<?php
$arr= array(
"first_name" => "Darian",
"last_name" => "Brown",
"age" => "28",
"email" => "darianbr@example.com"
);
?>
i have a .html file and i want to send my result from my .php file to .html file for further usage.
HTML by itself doesn’t do processing and can’t handle arrays.
You have two options, if it’s at page creation, insert a
phpsnippet that takes the array and generates appropriate HTML.If it’s after the page has been drawn, use a framework like
jQueryorJavaScriptto get the array from thephpfile (learn aboutJSONin this case, it will facilitate the work, see documentation here) and then modify the DOM accordingly.For example, if your script is accessed through
AJAX(likejQuery), you could do something like: