SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    Get my greedy down dotJoon's Avatar
    Join Date
    Apr 2003
    Location
    daejeon, South Korea
    Posts
    2,223
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    removing characters(XY) inside tag only

    Code:
    <?php 
    $myText='<table> 
      <tr> 
        <tdXYstyle="color:red">text1XYinXY1stXYtdXYofXY1stXYtr</td> 
        <tdXYclass="myClass">text2XYinXY2ndXYtdXYofXY1stXYtr</td> 
      </tr> 
      <tr> 
        <tdXYcolspan="2"XYclass="myClass">text3XYinXY1stXYtdXYofXY2ndXYtr</td> 
      </tr> 
    </table>';
    I have a variable $myText like the above.
    I like to remove 4 XYs which is inside between the open tag "<" and the close tag ">" without any touch of outside between the open tag "<" and the close tag ">".

    My target variable is like the following.
    Code:
    <?php 
    $myTargetText='<table> 
      <tr> 
        <td style="color:red">text1XYinXY1stXYtdXYofXY1stXYtr</td> 
        <td class="myClass">text2XYinXY2ndXYtdXYofXY1stXYtr</td> 
      </tr> 
      <tr> 
        <td colspan="2" class="myClass">text3XYinXY1stXYtdXYofXY2ndXYtr</td> 
      </tr> 
    </table>';
    How can I get $myTargetText from $myText?

  2. #2
    Non-Member
    Join Date
    Jun 2012
    Posts
    88
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    What is the code that sets the value to $myText ?

    It might be easier to edit that code so that your XY characters are not inserted where you don't want them in the first place.

  3. #3
    Get my greedy down dotJoon's Avatar
    Join Date
    Apr 2003
    Location
    daejeon, South Korea
    Posts
    2,223
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by kennard View Post
    What is the code that sets the value to $myText ?

    It might be easier to edit that code so that your XY characters are not inserted where you don't want them in the first place.
    The following is the code that sets the value to $myText.
    Code:
    $myText=str_replace(' ', 'XY ', $myText);
    I like to put &nbsp; instead of space.
    XY here menas &nbsp; .

  4. #4
    Non-Member
    Join Date
    Jun 2012
    Posts
    88
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Then this now looks like the same question you posted in your other thread.

    Why the cross-post?

  5. #5
    Get my greedy down dotJoon's Avatar
    Join Date
    Apr 2003
    Location
    daejeon, South Korea
    Posts
    2,223
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by kennard View Post
    Then this now looks like the same question you posted in your other thread.

    Why the cross-post?
    I thought I need to make it simplify the question for the answer posters. The former question is about putting special characters into both inside and outside tags and removing the special characters inside tags.

    This question is about the removig the special characters inside tags only.

    As you ask "What is the code that sets the value to $myText ?". It becomes the same question.
    I admit it has essentially the same point.


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
  •