Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialALBHAISI MOHAMMED
1,564 Pointsreplace hard code
Hello Team,
I am stuck at a request to replace the hardcode. I don't understand the question and don't know to go further. help please.
<?php
//edit this array
$contacts[] = [
'name' => 'Alena Holligan',
'email' => 'alena.holligan@teamtreehouse.com',
];
$contacts[] = [
'name' => 'Dave McFarland',
'email' => 'dave.mcfarland@teamtreehouse.com',
];
$contacts[] = [
'name' => 'Treasure Porth',
'email' => 'treasure.porth@teamtreehouse.com',
];
$contacts[] = [
'name' => 'Andrew Chalkley',
'email' => 'andrew.chalkley@teamtreehouse.com',
];
?>
2 Answers
rnw98613
348 PointsHere is solution;
$contacts = [
[
'name' => 'Alena Holligan',
'email' => 'alena.holligan@teamtreehouse.com'
],
[
'name' => 'Dave McFarland',
'email' => 'dave.mcfarland@teamtreehouse.com'
],
[
'name' => 'Treasure Porth',
'email' => 'treasure.porth@teamtreehouse.com'
],
[
'name' => 'Andrew Chalkley',
'email' => 'andrew.chalkley@teamtreehouse.com'
]
]
To access them use following expression;
$contacts[0]['name']; // will return 'Alena Holligan'
$contacts[0]['email']; // will return 'alena.holligan@teamtreehouse.com'
rnw98613
348 PointsPaste your code here;
ALBHAISI MOHAMMED
1,564 PointsALBHAISI MOHAMMED
1,564 PointsBummer: PHP Parse error: syntax error, unexpected '$contacts' (T_VARIABLE)