Skip to content

Instantly share code, notes, and snippets.

@geovanerocha
Created September 24, 2012 17:42
Show Gist options
  • Save geovanerocha/3777241 to your computer and use it in GitHub Desktop.
Save geovanerocha/3777241 to your computer and use it in GitHub Desktop.
Array manipulation exercise @ PHP.
<?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