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 trialLeon Segal
14,754 Pointspassing correct info to function?
Not sure I am even on the right track with this challenge!
Can someone advise?
<?php
include "helper.php";
/*
* helper.php contains
* $results->query("SELECT member_id, email, fullname, level FROM members");
*/
$data_set = $results->fetchAll(PDO::FETCH_NUM);
foreach($data_set as $row) {
send_offer(implode(",", $row));
}
1 Answer
Benjamin Payne
8,142 PointsHey Leon,
What you are doing there will implode all of the values of each array into a single comma separated string. You need to pass each index of the array individually or use call_user_func_array
like this:
<?php
include "helper.php";
/*
* helper.php contains
* $results->query("SELECT member_id, email, fullname, level FROM members");
*/
$rows = $results->fetchAll(PDO::FETCH_NUM);
foreach($rows as $row) {
call_user_func_array('send_offer', $row);
}
call_user_func_array reference
Hopefully that helps.
Thanks,
Ben