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 trialKer Sing Tan
10,573 Pointsarray_category ?
in the tutorial we store array_category inside $categories. May i ask array_category is an array or built in function of PHP?
$categories = array_category($catalog,$section);
foreach ($categories as $id) {
echo get_item_html($id,$catalog[$id]);
}
1 Answer
Ryan Groom
18,674 PointsKer Sing Tan array_category is neither an array or a built in function of PHP. array_category is a function, however, it is not a predefined function of PHP. It was created by you and the Team TreeHouse instructor.
Ker Sing Tan
10,573 PointsKer Sing Tan
10,573 PointsThank you . Oh I thought function need to add "function" before the function name like :
$categories = function array_category($catalog,$section);
Thank you =)
Ryan Groom
18,674 PointsRyan Groom
18,674 Points@Ker Sing Tan actually you do need to add function before declaring a function in PHP. If you notice in the video at the top of the workspace there are various tabs that represent the files that she is working with. There is a point in the video where she clicks on the "functions.php" file/tab (2:20). When she opens that file you can see that she created "function array_category()" and that she is writing the code that should be performed when calling that function later in the lesson.