note 48733 added to ref.strings

From: Date: Wed, 05 Jan 2005 16:46:17 +0000
Subject: note 48733 added to ref.strings
Groups: php.notes 
Request: Send a blank email to php-notes+get-82792@lists.php.net to get a copy of this message
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.... ---- Manual Page -- http://www.php.net/manual/en/ref.strings.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+48733 Delete -- http://master.php.net/manage/user-notes.php?action=delete+48733&report=yes Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+48733&report=yes&reason=bad+code Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+48733&report=yes&reason=spam Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+48733&report=yes&reason=useless+example Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+48733&report=yes&reason=contains+commercial+links Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+48733&report=yes&reason=useless+note Reject -- http://master.php.net/manage/user-notes.php?action=reject+48733&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#82792) next »