left

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Marco J.L

    left

    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,helvetic a,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>$fil e\n";
    }
    }
    closedir($handl e);
    ?>

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

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

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

    Marco J.L.



  • Steve

    #2
    Re: left

    On Wed, 06 Apr 2005 21:58:40 +0200, Marco J.L wrote:
    [color=blue]
    > 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,helvetic a,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>$fil e\n";
    > }
    > }
    > closedir($handl e);
    > ?>
    >
    > </body>
    > </html>
    > =======RESULT ========
    > 200503290000.tx t
    > 200503300000.tx t
    > 200503310000.tx t
    > 200504010000.tx t
    >
    > =======But I want this result : ======
    > 200503290000
    > 200503300000
    > 200503310000
    > 200504010000
    >
    > =============== ====
    > Thanx,
    >
    > Marco J.L.[/color]

    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

    Comment

    • Ken Robinson

      #3
      Re: left


      Marco J.L wrote:[color=blue]
      > Hello,
      >
      > how can I change the lenght of an value in basuc it's called LEFT or[/color]
      RIGHT[color=blue]
      > and MID . I read the filenames but I want to strip the extension from[/color]
      the[color=blue]
      > filename.
      >
      > ======== SCRIPT ==============
      > <table style="font-family: tahoma,helvetic a,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>$fil e\n";
      > }
      > }
      > closedir($handl e);
      > ?>
      >
      > </body>
      > </html>
      > =======RESULT ========
      > 200503290000.tx t
      > 200503300000.tx t
      > 200503310000.tx t
      > 200504010000.tx t
      >
      > =======But I want this result : ======
      > 200503290000
      > 200503300000
      > 200503310000
      > 200504010000
      >
      > =============== ====[/color]

      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

      Comment

      Working...