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 trial

PHP Build a Simple PHP Application Working With Functions Creating the Shirt Display Function

two arguments in custom function

hello, i do not understand why echo get_list_view_html (and the custom function itself) has two arguments ($product, $productid). what exactly is our custom function doing with those arguments/variables?

thank you so much! i watched it several times, but can't understand it

5 Answers

thank you for your reply,

i had to think and google about it for another hour to actually get it though.

i just didn't understand where those variables/arrays are defined. now i get it, that the foreach function is more structured than i was tought :P

foreach($array as $key => value); foreach($array as $value);

still i am not sure what this means: get_list_view_html($product, $productid);

$product and $productid are required for this function, right? is foreach the only way to talk to them? can someone point out, how to specify this in another way?

thank you so much! i try to do all the thinking myself, but i was stuck for a whole day.

This function displays the products on the page.

$product is an array and for specify what is the element to display we need his ID.

thank you so much!

Hey Daniel, same here!

I don't understand if this arguments have any meaning with the actual code within the function or outside of it.

Not sure if it's there because it needs to communicate with those variables or not. Could we use different arguments?

What is the relation between those arguments and the variables $product_id and $product ?

Can we still use this function using a different arguments? No, why?

Thank you