As a beginner I know how to work with basic for and foreach loops in PHP. Most of the time we prefer foreach for arrays. I am asking this just for the sake of insight into this "for loop" behavior and how it varies compared with javascript. The same loop in Javascript gives us results. (Experts feel the question is insane pls don't downvote it)
Javascript
var arrayList = ["php", "javascript", "c++", "C lang", "Python"];
var text = "";
for(var i = 0; i < arrayList.length; i++)
{
text += arrayList[i] + "<br>";
}
document.write(text);
PHP-I know it will work if I put the variable in the loop, but why not in PHP
$_array = array("PHP", "Javascript", "C++", "Jquery", "Python");
$total = count($_array);
$result = "";
for($i = 0; $ i <$total; $i++)
{
$result += $_array[$i]."<br>";
}
echo $result;