PHP Crew: question about substr.

Discussion in 'OT Technology' started by brds, Mar 27, 2008.

  1. brds

    brds OT Supporter

    Joined:
    Jun 26, 2006
    Messages:
    17,650
    Likes Received:
    15
    Location:
    Atlanta
    How can i make substr display and apostrophe?

    example of what's going on:
    Code:
    $string = "what's going on.";
    echo substr($string, 0, 7);
    
    Result:
    Code:
    what
    
    CLIFFS: once substr hits a ' it stops processing the string. :wtc:
     
  2. skinjob

    skinjob Active Member

    Joined:
    Jan 6, 2001
    Messages:
    2,337
    Likes Received:
    0
    Location:
    Aztlán
    You probably have to escape the single quote...
    $string = "what\'s ..."
     
  3. CyberBullets

    CyberBullets I reach to the sky, and call out your name. If I c

    Joined:
    Nov 13, 2001
    Messages:
    11,865
    Likes Received:
    0
    Location:
    BC, Canada/Stockholm, Sweden
    <?php
    $string = "what's going on.";
    echo substr($string, 0, 7);
    ?>

    copy output
    PhpMate r8268 running PHP 5.2.3 (cli) (//Applications/xampp/xamppfiles/bin/php)
    >>> untitled

    what's
    Program exited.


    run's fine here?
     

Share This Page