Skip to content

Instantly share code, notes, and snippets.

@angch
Created November 12, 2013 19:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save angch/7437437 to your computer and use it in GitHub Desktop.
Save angch/7437437 to your computer and use it in GitHub Desktop.
<?php // Use proper tags, not everyone is coding in PHP!
// Use proper, *working* code please. Not everyone wants to retype your homework.
$tahun = array(2011, 2012, 2013);
$nama = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I');
// Homework: Go read and understand:
// http://php.net/manual/en/ref.array.php
// Formatted for readability
$nama2 = array_fill(0, sizeof($tahun), array());
$i = 0;
foreach ($nama as $n) {
$nama2[$i++][] = $n;
$i = $i >= sizeof($tahun) ? 0 : $i;
}
print_r($nama2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment