Created
June 29, 2012 05:01
-
-
Save cha0s/3015877 to your computer and use it in GitHub Desktop.
This file contains 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 | |
// This: | |
$slides = array( | |
"http://local.dh2i.com/images/slides/slide1.png", | |
"http://local.dh2i.com/images/slides/slide2.png", | |
"http://local.dh2i.com/images/slides/slide3.png", | |
"http://local.dh2i.com/images/slides/slide4.png", | |
); | |
// Can be done like this: | |
$slides = array(); | |
foreach (array(1, 2, 3, 4) as $index) { | |
$slides[] = "http://local.dh2i.com/images/slides/slide$index.png"; | |
} | |
// Or, for max win (functional approach): | |
$slides = array_map(function($e) { | |
return "http://local.dh2i.com/images/slides/slide$e.png"; | |
}, array(1, 2, 3, 4)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment