+ 22
[Solved]PHP array in HTML
Expected output: 42 Actual output: "42"); echo $arr["SoloLearn"]; ?> Please could someone explain how to fix this? In PHP (works fine): <?php $arr = array("SoloLearn"=>"42"); echo $arr["SoloLearn"]; ?> In HTML (doesn't work): <!DOCTYPE html> <html> <head> <title>Page Title</title> </head> <body> <?php $arr = array("SoloLearn"=>"42"); echo $arr["SoloLearn"]; ?> </body> </html>
5 Answers
+ 8
PHP cannot run in .html files. but html can run in php. Try to put html in PHP compiler not in opposite. hope it helps
+ 3
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<?php // Try it from inside the Compiler folder (php, IIS, .... etc)
$arr = array("SoloLearn"=>"42");
echo $arr["SoloLearn"];
$eld = array("san","man","dan","fan");
echo "<br>". $eld[3];
$san = array("dana"=>"lolo","sana"=>33);
echo "<br>". $san["sana"]+=5;
echo "<br>". $san["sana"];
?>
</body>
</html>
+ 1
The html code of https://code.sololearn.com/WlA1mrc28Lwg/?ref=app, should be in php file.
+ 1
you can include your html file into your php code by using include statement and vice versa
0
right html code ishttps://code.sololearn.com/WlA1mrc28Lwg/?ref=app
but html program run