Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
PHP: substr
<?php
$images = array(
'logo.png',
'background.jpg',
'http://www.hardcoregamer.com/wp-content/uploads/2014/03/BAK_Sshot019.jpg'
);
foreach ($images as $image) {
$src = (substr($image,0,4) == 'http') ? $image : "images/$image";
echo $src . "<br />";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.