I'm trying to echo an array value from an array that was created using the following code. The data for the array is pulled from a MySQL table.
$names = $db->fetchAll("select `name` from `classes`");
This is what is stored in the $names variable
Array ( [0] => Array ( [name] => Web Design ) [1] => Array ( [name] => Art History ) [2] => Array ( [name] => Gym ) [3] => Array ( [name] => English ) [4] => Array ( [name] => Biology ) [5] => Array ( [name] => 3D Animation ) [6] => Array ( [name] => Tech Disc ) [7] => Array ( [name] => Math ) [8] => Array ( [name] => Dance ) [9] => Array ( [name] => Video Production ) [10] => Array ( [name] => Home Ec ) [11] => Array ( [name] => Government ) [12] => Array ( [name] => Physics ) )
I'm attempting to echo a [name] value OR all [name] values, but I can't figure it out. I've tried the following....
<?php echo $names['name'];?>
returns nothing
<?php echo $names['0'];?> //AND\\ <?php echo $names[0];?>
Both return the string Array
Can someone please help me echo a single value from the array?
Example: Web Design or Art History
Also can someone please help me echo all the values from the array?
Example: Web Design Art History Gym English Biology ......