By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,400 Members | 1,334 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,400 IT Pros & Developers. It's quick & easy.

left

P: n/a
Hello,

how can I change the lenght of an value in basuc it's called LEFT or RIGHT
and MID . I read the filenames but I want to strip the extension from the
filename.

======== SCRIPT ==============
<table style="font-family: tahoma,helvetica,arial; font-size: 12px;
font-weight: bold; color: #000000">
<?php
$handle=opendir('news');
while (false!==($file = readdir($handle))) {
if ($file != "." && $file != "..") {
echo "\n<TR><TD>$file\n";
}
}
closedir($handle);
?>

</body>
</html>
=======RESULT ========
200503290000.txt
200503300000.txt
200503310000.txt
200504010000.txt

=======But I want this result : ======
200503290000
200503300000
200503310000
200504010000

===================
Thanx,

Marco J.L.

Jul 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
On Wed, 06 Apr 2005 21:58:40 +0200, Marco J.L wrote:
Hello,

how can I change the lenght of an value in basuc it's called LEFT or RIGHT
and MID . I read the filenames but I want to strip the extension from the
filename.

======== SCRIPT ==============
<table style="font-family: tahoma,helvetica,arial; font-size: 12px;
font-weight: bold; color: #000000">
<?php
$handle=opendir('news');
while (false!==($file = readdir($handle))) {
if ($file != "." && $file != "..") {
echo "\n<TR><TD>$file\n";
}
}
closedir($handle);
?>

</body>
</html>
=======RESULT ========
200503290000.txt
200503300000.txt
200503310000.txt
200504010000.txt

=======But I want this result : ======
200503290000
200503300000
200503310000
200504010000

===================
Thanx,

Marco J.L.


substr ( $name, 0, strlen ( $name ) - strlen ( '.txt' ) ); or
substr ( $name, 0, strrpos ( $name, '.' ) );

I'm probably the odd character out, but you get the idea...
Steve

Jul 17 '05 #2

P: n/a

Marco J.L wrote:
Hello,

how can I change the lenght of an value in basuc it's called LEFT or RIGHT and MID . I read the filenames but I want to strip the extension from the filename.

======== SCRIPT ==============
<table style="font-family: tahoma,helvetica,arial; font-size: 12px;
font-weight: bold; color: #000000">
<?php
$handle=opendir('news');
while (false!==($file = readdir($handle))) {
if ($file != "." && $file != "..") {
echo "\n<TR><TD>$file\n";
}
}
closedir($handle);
?>

</body>
</html>
=======RESULT ========
200503290000.txt
200503300000.txt
200503310000.txt
200504010000.txt

=======But I want this result : ======
200503290000
200503300000
200503310000
200504010000

===================


I'm not sure what your "Subject" line or the first part of your
question has to do with the second part, but you should take a look at
the substr() function <http://www.php.net/substr> and the pathinfo()
function <http://www.php.net/pathinfo>.

Combining those should give you what you're looking for.

Ken

Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.