note 33764 deleted from ref.strings by aidan

From: Date: Tue, 28 Sep 2004 12:12:04 +0000
Subject: note 33764 deleted from ref.strings by aidan
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-77494@lists.php.net to get a copy of this message
Note Submitter: MDonatas at centras dot lt ---- I had to "translate" some project from ASP to PHP and found that in ASP there are some very useful string functions like: string left ( string string, int length ) string right ( string string, int length ) string mid ( string string, int start [, int length] ) I think it's not hard to figure out what these functions do. If anyone finds it useful (I did), here is the code: function left ($str, $howManyCharsFromLeft) { return substr ($str, 0, $howManyCharsFromLeft); } function right ($str, $howManyCharsFromRight) { $strLen = strlen ($str); return substr ($str, $strLen - $howManyCharsFromRight, $strLen); } function mid ($str, $start, $howManyCharsToRetrieve = 0) { $start--; if ($howManyCharsToRetrieve === 0) $howManyCharsToRetrieve = strlen ($str) - $start; return substr ($str, $start, $howManyCharsToRetrieve); }

« previous php.notes (#77494) next »