concatanating something on to end of substr

Discussion in 'PHP' started by liam1412, Aug 7, 2007.

  1. #1
    I remeber seeing a way to concat something on the end of a substr query.

    ie

    I want to add ............. at the end

    so it would read

    This is too long to fit in the ..........

    using substr('$string' ,0,25);

    Thanks
     
    liam1412, Aug 7, 2007 IP
  2. sarahk

    sarahk iTamer Staff

    Messages:
    28,899
    Likes Received:
    4,555
    Best Answers:
    123
    Trophy Points:
    665
    #2
    I'm not sure about your use of quotes... try this example

    <?PHP
    $a = 'A quick brown fox jumped over the lazy dog';
    $b = substr($a,0,25).'...';
    echo $b;
    ?>
    PHP:
     
    sarahk, Aug 7, 2007 IP
  3. liam1412

    liam1412 Active Member

    Messages:
    387
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    60
    #3
    Works a treat ta
     
    liam1412, Aug 7, 2007 IP
  4. gwkg

    gwkg Peon

    Messages:
    143
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #4
    You mentioned the word query... are you using substr in mysql or php only? You can CONCAT directly in your MySql query, as well.
     
    gwkg, Aug 7, 2007 IP