note 89157 modified in function.substr by danbrown

From: Date: Tue, 24 Feb 2009 15:35:53 +0000
Subject: note 89157 modified in function.substr by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-151073@lists.php.net to get a copy of this message
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' ?> --was-- Here's a simple direct way of extracting the information you need from a string... Suppose your string is "C:/www/vhosts/judorsh.com/mofa/images/neewhang1.jpg" which points to an image. Let's assume you want the part "images/neewhang1.jpg". We have to do the ff: $image="C:/www/vhosts/judorsh.com/mofa/images/neewhang1.jpg" $image=substr($image,strpos($image,'image', (strlen($image)-strpos($image,'image')))); echo $image."<br/>"; //will give 'images/neewhang1.jpg' http://php.net/manual/en/function.substr.php

« previous php.notes (#151073) next »