Created
September 15, 2014 13:15
-
-
Save vienhoang/03b90bd5f2fe174b7874 to your computer and use it in GitHub Desktop.
PHP: substr
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 | |
$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