SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Feb 2007
    Posts
    62
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    str_replace function

    Hi Guys
    I'm kind of lost with str_replace I need to correct the outcome with str_replace('&',"&amp;" Before the validation it was like this : <td>' . $example . '</td>
    Then I try to incorporate two parts together and got some problems. Please show me how it suppose to be properly incorporated these two parts

    PHP Code:
    //My wrong solution
    <td class="tded">' . str_replace('&',"&amp;", ' $expdeal ') . '</td>

    //How it suppose to be?
    1.   str_replace('&',"&amp;"
    2.   <td>' . $example . '</td

  2. #2
    SitePoint Enthusiast
    Join Date
    Jun 2007
    Location
    Ukraine
    Posts
    84
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Why do not you want to use htmlspecialchars or something similar?

  3. #3
    SitePoint Evangelist mad-onion's Avatar
    Join Date
    Aug 2000
    Location
    Land of the long white cloud
    Posts
    556
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    As dzysyak says php does have functions to do this but if you still want to use your method then the code should look like...

    echo '<td class="tded">' . str_replace('&',"&amp;",$example ) . '</td>';
    SiteOptions >> Services :: Products :: Contact
    Developers of PHP, C++, Visual Basic, MySQL, and more!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •