jay johnston dot com
mootools php faith camera linux

php

Code Challenge - Double an Array



what is wrong with this code:



// pull these columns from the pages table
$a = array('title','keywords','description','body');

// double the array with columns postfixed "_spanish"
for($i=0;$i<count($a);$i++) $a[] = $a[$i].'_spanish';

// dump the columns that will be pulled
die('<pre>'.print_r($a,true));



1 point for guessing the output (without running it)
10 points for coming up with one line that fixes it

first to respond with the most points wins.



Last Updated: 2009-07-07 14:23:19

Creative Commons License Valid XHTML 1.0 Transitional Powered by PHP
Jay Johnston is a Zend Certified Engineer in PHP 5