SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  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)

    changing myString

    Code:
    code
    
    <?php
    
    $myString = '11-22-33';
    
    echo $myString;
    
    
    ?>  
    
    
    result
    
    11-22-33
    The code above produce the result above.


    I like to change from "-" to "+".

    The following would-be code doesn't work correctly, but it will show what I want.

    Code:
    would-be code
    
    
    <?php
    
    $myString = '11-22-33';
    
    $myStringChanging = 
    changingMystring($myString, from '-' to '+');
    
    echo $myStringChanging;
    
    
    ?>  
    
    target result
    
    11+22+33
    How can I get my target result above from $myString "11-22-33?"

  2. #2
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,807
    Mentioned
    158 Post(s)
    Tagged
    3 Thread(s)
    Hi joon
    use str_replace if using basic string manipulation:
    PHP Code:
    $myString '11-22-33';
    $myStringChanging str_replace("-""+"$myString);
    echo 
    $myStringChanging
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  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)
    Thank you very much, spikeZ.


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
  •