Skip to content

Instantly share code, notes, and snippets.

@cha0s
Created June 29, 2012 05:01
Show Gist options
  • Save cha0s/3015877 to your computer and use it in GitHub Desktop.
Save cha0s/3015877 to your computer and use it in GitHub Desktop.
<?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