1<?php
2$age=array("Peter"=>"35","Ben"=>"37","Joe"=>"43");
3foreach($age as $x=>$x_value)
4 {
5 echo "Key=" . $x . ", Value=" . $x_value;
6 echo "<br>";
7 }
8?>
1$id = 1;
2$age = 2;
3$sort = "id"; // or "age";
4 $Key = $$sort;
5$arr = array($Key => 'string');
6
7print_r($arr);