0

I want to use array element as a variable in for loop where $arr1[$i] is written it is not working please help me ....

<!DOCTYPE html>
<html>
<body>
<?php 
$shivam=12;
$raju=11;
$rakesh=10;
$arr1=array('shivam','raju','rakesh');
for ($x = 0; $x < 3; $x++) {
  echo "The name is: $$arr1[$x] <br>";
}
?>  
</body>
</html>
2
  • Put it in braces: ${$arr1[$x]} Commented Sep 19, 2022 at 16:46
  • echo "The name is: {${$arr1[$x]}} <br>"; Commented Sep 19, 2022 at 16:47

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.