$i = 'i';
$arr = array('hi' => 'test');
echo "$arr[h$i]";exit();
What's the right version to do it without {}?
Say,I know can do it with "{$arr['h' . $i]}"
EDIT
1.inside "" 2.with operation like ".",i.e,['h' . $i] 3.without {}
$i = 'i';
$arr = array('hi' => 'test');
echo "$arr[h$i]";exit();
What's the right version to do it without {}?
Say,I know can do it with "{$arr['h' . $i]}"
EDIT
1.inside "" 2.with operation like ".",i.e,['h' . $i] 3.without {}
If you don't want {}, you'll need to do it this silly way:
$idx = "h$i";
echo "$arr[$idx]";exit();
Of course, you could also just do
$i = 'i';
$arr = array('hi'=>'test');
echo $arr["h$i"]; exit();
But I think maybe you oversimplified things for the purposes of your question.