note 75253 deleted from function.substr by tularis

From: Date: Mon, 31 Dec 2007 10:49:02 +0000
Subject: note 75253 deleted from function.substr by tularis
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-134615@lists.php.net to get a copy of this message
Note Submitter: miskotes at yu-corner dot com ---- /*#################################### 'A good thing is working with added values like .NET or C# 'Here is a full copy/paste */################################### # <?php # Written by miskotes @ 20th fo May 2007 $filenameToUpper = "Hi_Iam_toto_thomas_etc1_etc2_etc3"; $filenameToUpper = substr($filenameToUpper, 0, 19); $toFind = "_"; $filenameToUpper = strrev($filenameToUpper); # The first time $result = strchr($filenameToUpper, $toFind); $result = strrev($result); # The second time $result = substr($result, 0, -1); # Take off last found $toFind = "_" # Don't be confused here the ultimate zero as 1st is not needed ;) echo $result; # This displays trimmed string as word before 19th character if $toFind = True # Else by default is previous found "_"! ?> # # End

« previous php.notes (#134615) next »