I have made a small static test script for just explain what i want to do.
<?php
$test = "hello";
$demo = "php";
$x = array("hello"=>"world","php"=>"script");
echo $x[$test]."<br />";
echo $x[$demo];
?>
OUTPUT: world
script
How could i get same output dynamically when values are come from database.
$result = mysql_query("SELECT font FROM stone");
while($row = mysql_fetch_array($result))
{
echo $x[$row['font']]."<br/>";// values of $row['font'] are 'test' and demo
}
1 Answer