note 48733 deleted from ref.strings by nlopess
| From: | nlopess@php.net | Date: | Tue, 08 Mar 2005 20:23:01 +0000 |
| Subject: | note 48733 deleted from ref.strings by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-86131@lists.php.net to get a copy of this message | ||
Note Submitter: HOELEC2 at WANADOO dot FR
----
I tried another implementation to achieve the same goal, using arrays this time :
<?
$var_string = "/home/username/www/index.php";
$var_string_exp = explode("/",$var_string);
$var_string_exp2 = array_slice($var_string_exp, 0,4);
$result = implode("/",$var_string_exp2);
echo $result;
?>
The result is /home/username/www.
You can change the value in array_slice to retrieve any part of the string (0 being the offset and 4
the number of elements retrieved) .
That's just another way of doing it....