Here’s my code:
$quizId = '';
foreach ($module['QuizListing'] as $quizListing) {
if ($quizListing['id']) {
$quizId = $quizListing['id'];
break;
}
}
Is there a better way of doing this?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
What you’re doing is reasonable assuming that:
I assume from your question that one of both of these is not true. If you want the first quiz listing then do this:
The
reset()function returns the first element in the array (orfalseif there isn’t one).This assumes every quiz listing has an ID. If that’s not the case then you can’t get much better than what you’re doing.