SPECIAL OFFER: Only $59 for access to everything in OSTraining for 1 year! You save $85!  1
Join today and get access to 1,000's of books and videos. Learn WordPress, Drupal, Magento, Joomla and more! Sign up today!

Another poorly worded question

3 years 5 months ago #123549 by Cockroach
Another poorly worded question was created by Cockroach
"apples", "bananas", and "papayas" are in the variable "fruits". What will output "papayas"?
echo $fruits[1];
echo $fruits[2];
echo $fruits[3];

Probably meant: "apples", "bananas", and "papayas" are elements in the array "fruits". What will output "papayas"?
echo $fruits[1];
echo $fruits[2];
echo $fruits[3];

Please Log in to join the conversation.

3 years 5 months ago - 3 years 5 months ago #123575 by Valentin
Replied by Valentin on topic Another poorly worded question
Hi Cockroach,

If $fruits is an array and the values are that exact order ("apples", "bananas", and "papayas"), to print "papayas" use:
echo $fruits[2];

To get the first value of an Array use the position 0

Kind regards,
Valentín

Follow us on Twitter - twitter.com/OSTraining
Like us on Facebook - facebook.com/ostraining

Please Log in to join the conversation.

3 years 5 months ago #123576 by Cockroach
Replied by Cockroach on topic Another poorly worded question
I agree! I understand why I missed it. However, the issue is the list is NOT a variable. It is an array! I thought it to be a poor choice of words & goes contrary to the terms taught in the course lesson.

Please Log in to join the conversation.

3 years 5 months ago #123578 by Valentin
Replied by Valentin on topic Another poorly worded question
May you elaborate? Share the code involved to have a clear idea.

Follow us on Twitter - twitter.com/OSTraining
Like us on Facebook - facebook.com/ostraining

Please Log in to join the conversation.

3 years 5 months ago #123579 by Cockroach
Replied by Cockroach on topic Another poorly worded question
The question states: "apples", "bananas", and "papayas" are in the variable "fruits". This list is not a variable! It is an array! Does that help explain why I see the wording of the question to be poor?

Please Log in to join the conversation.

3 years 5 months ago #123585 by Valentin
Replied by Valentin on topic Another poorly worded question
In that case, my first suggestion should help.

Kind regards,
Valentín

Follow us on Twitter - twitter.com/OSTraining
Like us on Facebook - facebook.com/ostraining
The following user(s) said Thank You: Cockroach

Please Log in to join the conversation.

3 years 5 months ago #123587 by Cockroach
Replied by Cockroach on topic Another poorly worded question
Agreed! I thought you were explaining why the answer I selected was incorrect. We agree, the question is poorly worded.

Please Log in to join the conversation.

3 years 5 months ago #123591 by Valentin
Replied by Valentin on topic Another poorly worded question
Don't worry :)

Let us know if we can help you in something else

Kind regards,
Valentín

Follow us on Twitter - twitter.com/OSTraining
Like us on Facebook - facebook.com/ostraining

Please Log in to join the conversation.

3 years 5 months ago #124553 by samantha32
Replied by samantha32 on topic Another poorly worded question
I would encourage you not to get involved in semantics. An array is a type of variable I would say... but I am a budding programmer.

You may like the Head First PHP book (new edition is out). But even they take shortcuts.

Please Log in to join the conversation.

3 years 5 months ago #124569 by Nick
Replied by Nick on topic Another poorly worded question
Hi Roger,

Good catch! For the quiz, I switched the word "variable" to "array" instead.

Thanks!

Kind regards,
Nick

Follow us on Twitter - twitter.com/OSTraining
Like us on Facebook - facebook.com/ostraining

Please Log in to join the conversation.

Join today and get access to 1,000's of books and videos. Learn WordPress, Drupal, Magento, Joomla and more! Sign up today!