Created
September 24, 2012 17:42
-
-
Save geovanerocha/3777241 to your computer and use it in GitHub Desktop.
Array manipulation exercise @ PHP.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$data = array( | |
array(1,2,3,4,8), | |
array(5,6,7,9,14), | |
array(10,11,12,13,18), | |
array(20,19,17,16,15) | |
); | |
// Output the numbers in order, comma spereated | |
// 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20 | |
$results = array(); | |
foreach ($data AS $segment) { | |
$results = array_merge($results, $segment); | |
} | |
sort($results); | |
echo implode(',', $results); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment