₦airaland Forum

Welcome, Guest: RegisterLoginWith GoogleTrendingRecentNew

Stats: 3,331,189 members, 8,449,050 topics. Date: Tuesday, 21 July 2026 at 09:03 AM

Toggle theme

PHP Simple Puzzle - Webmasters (3) - Nairaland

Nairaland ForumScience/TechnologyWebmastersPHP Simple Puzzle (4115 Views)

1 2 3 Reply

Re: PHP Simple Puzzle by romme2u: 12:45am On Jul 18, 2013
Web Contractor: I must say,you attacked it nicely.Just a little explanation for learners to follow.

Foreach loops can only be used with arrays.
it has the format

<?php
foreach($array as $value){
statement;
}
?>

Foreach loop will go through every single element of the array($array) and each of the elements(2,4,6,8,10,12) will become the value($value) which can then be referenced in the statement.

Simply put,we are pulling each of the elements in the array and assigning them to a variable name temporarily, and then executing a statement on them.
that bolded section should be
foreach($key=>$value){execute statement here}
since arrays consists of keys and values.
1 2 3 Reply

Web Masters Please Help Me Solve This PuzzleI Challenge The Level Of Intelligence On This Forum With This Puzzle.234

New! Supercharge Your Website With Our Unlimited Web Hosting, Only ₦2700 1st YrNew USSD Code For Keystone BankHow To Sell Mtn Sme Data Without Manually Sending Sms Or Dialing The Ussd Codes