Needing help changing content of a variable

Discussion in 'PHP' started by ziplock122949, Feb 20, 2011.

  1. #1
    I have an rss pulling script that I need help with. For the summary, i need to change all the apostrophes that are pulled ( ' ) into ( \' )
    $summary = $item['summary'];	
    $summary = substr($summary,0,240)."...";
    line that changes all ' to \'
    Code (markup):

     
    ziplock122949, Feb 20, 2011 IP
  2. jwitt98

    jwitt98 Peon

    Messages:
    145
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #2
    
    $summary = "That's your's don't y'know?";
    $summary = preg_replace("/\'/", "\\\'", $summary);
    echo $summary;
    PHP:
    This will produce:
    That\'s your\'s don\'t y\'know?
     
    jwitt98, Feb 20, 2011 IP
  3. ziplock122949

    ziplock122949 Active Member

    Messages:
    159
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    60
    #3
    Worked. Thanks.
     
    ziplock122949, Feb 20, 2011 IP