₦airaland Forum

Welcome, Guest: Register • Login • With Google • Trending • Recent • New

Stats: 3,344,248 members, 8,510,839 topics. Date: Saturday, 31 October 2026 at 08:46 AM

Toggle theme

PHP Simple Puzzle - Webmasters (3) - Nairaland

Nairaland Forum › Science/Technology › Webmasters › PHP Simple Puzzle (4179 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 Puzzle • I Challenge The Level Of Intelligence On This Forum With This Puzzle. • 2 • 3 • 4

Secrets In Making Money Online And Making A Living From The Internet • Why Linda Ikeji Would Have Failed If She Started Blogging 2013 • Nairaomm - Buy Bitcoins, Perfect Money, Paypal, Payer, Payoner, Webmoney