note 83250 added to function.substr

From: Date: Fri, 16 May 2008 17:54:48 +0000
Subject: note 83250 added to function.substr
Groups: php.notes 
Request: Send a blank email to php-notes+get-139451@lists.php.net to get a copy of this message
In response to: "dev at arthurk dot com" Your code: <?php $file_basename = substr($filename, 0, strripos($filename, '.')); // strip extention $file_ext = substr($filename, -1 * strripos($filename, '.')); ?> The second line don't work. This code work fine: <?php $file_basename = substr($filename, 0, strripos($filename, '.')); // strip extention $file_ext = substr($filename, strripos($filename, '.')); ?> Example: $filename="anything.jpg" strripos($filename, '.'); -> position 8 substr($filename, -1 * 8); -> "hing.jpg" (-8 chars from end) But: substr($filename, 8); -> ".jpg" (starts in the char number 8) Sorry for my english, and, "dev at arthurk dot com", sorry, i don't disturb you, only want contribute. Open Source is revolution!!! -;) ---- Server IP: 80.64.47.13 Probable Submitter: 81.202.143.105 ---- Manual Page -- http://www.php.net/manual/en/function.substr.php Edit -- https://master.php.net/note/edit/83250 Del: integrated -- https://master.php.net/note/delete/83250/integrated Del: useless -- https://master.php.net/note/delete/83250/useless Del: bad code -- https://master.php.net/note/delete/83250/bad+code Del: spam -- https://master.php.net/note/delete/83250/spam Del: non-english -- https://master.php.net/note/delete/83250/non-english Del: in docs -- https://master.php.net/note/delete/83250/in+docs Del: other reasons-- https://master.php.net/note/delete/83250 Reject -- https://master.php.net/note/reject/83250 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#139451) next »