Re: while-question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Jochem Maas wrote:
$a = range(1,10);
for ($i = 0, $c = count($a); $i < $c; print($a[$i]."\n"), $i++);

think the point of this is to count the items in an array without count mate :p no point in the above you could just:
$c = count($a);

foreach!
$a = range(1,10);
$c = 0;
foreach($a as $b) {
 $c++;
}
echo $c. PHP_EOL;

if you really want a challenge try this one..

task: add the numbers 5 and 17 together, using php, without using the + operator. fill it in:

function add($a , $b) {
 //code here but no + - / * operators
 return $answer;
}

echo add(5, 17);

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux