If I have the following code:
$employeeAges;
$employeeAges["Lisa"] = "28";
$employeeAges["Jack"] = "16";
$employeeAges["Ryan"] = "35";
$employeeAges["Rachel"] = "46";
$employeeAges["Grace"] = "34";
foreach( $employeeAges as $name => $age){
echo "Name: $name, Age: $age <br />";
}
How can I output specific information? Below is a wrongly written example:
foreach( $employeeAges as $name => $age ) {
$selective = $name["Lisa"]->$age;
$secondary = $name["Grace"]->$age;
echo "The person you're looking for is $selective years old. And the other one is $secondary years old.";
}
As you see, I want to grab only the $value of specifics $key. The code above output the following error:
Trying to get property of non-object
Can someone please help with this piece of code? Greatly appreciated.