note 89157 deleted from function.substr by googleguy
| From: | googleguy@php.net | Date: | Tue, 16 Oct 2012 11:56:33 +0000 |
| Subject: | note 89157 deleted from function.substr by googleguy | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-191326@lists.php.net to get a copy of this message | ||
Note Submitter: jude dot dadzie at gmail dot com
----
Here's a simple direct way of extracting the information you need from a string...
Suppose your string is "C:/www/vhosts/example.com/images/image1.jpg" which points to an
image. Let's assume you want the part "images/image1.jpg". We have to do the ff:
<?php
$image="C:/www/vhosts/example.com/images/image1.jpg"
$image=substr($image,strpos($image,'image',
(strlen($image)-strpos($image,'image'))));
echo $image."<br/>"; //will give 'images/image1.jpg'
?>