note 75253 added to function.substr
| From: | miskotes at yu-corner dot com | Date: | Sun, 20 May 2007 18:15:57 +0000 |
| Subject: | note 75253 added to function.substr | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-126771@lists.php.net to get a copy of this message | ||
/*####################################
'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
----
Server IP: 193.95.141.37
Probable Submitter: 194.125.71.249
----
Manual Page -- http://www.php.net/manual/en/function.substr.php
Edit -- https://master.php.net/note/edit/75253
Del: integrated -- https://master.php.net/note/delete/75253/integrated
Del: useless -- https://master.php.net/note/delete/75253/useless
Del: bad code -- https://master.php.net/note/delete/75253/bad+code
Del: spam -- https://master.php.net/note/delete/75253/spam
Del: non-english -- https://master.php.net/note/delete/75253/non-english
Del: in docs -- https://master.php.net/note/delete/75253/in+docs
Del: other reasons-- https://master.php.net/note/delete/75253
Reject -- https://master.php.net/note/reject/75253
Search -- https://master.php.net/manage/user-notes.php