Implement $data=str_replace(" ",",",$data);

Discussion in 'PHP' started by Luke Jones, Jul 7, 2007.

  1. #1
    I need some guidance on how to correctly implement the line:
    $data=str_replace(" ",",",$data);
    Where do I add it, and do I need other commands, for example function (){ ?

    Thanks
     
    Luke Jones, Jul 7, 2007 IP
  2. MMJ

    MMJ Guest

    Messages:
    460
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I really don't understand what you mean. :eek:
     
    MMJ, Jul 7, 2007 IP
  3. Nefarious

    Nefarious Peon

    Messages:
    36
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    $data is your string
    str_replace(old,new,string);


    So if you want to replace the character A in $data with an underscore:

    $data= str_replace('A','_',$data);


    Now $data has no A characters, they are now underscores.
     
    Nefarious, Jul 7, 2007 IP
  4. Luke Jones

    Luke Jones Peon

    Messages:
    427
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Yes, I understand this.
    I'm using this line to remove the space between words in a search query so that rss feeds do not break. Spaces cause the feeds to return an error. For example, "music album" needs to be "music,album".
    But, I don't know where to add this line in my search engine script.
    Where does it usually go?
    Is it accompanied by other commands?

    Thanks
     
    Luke Jones, Jul 7, 2007 IP
  5. MMJ

    MMJ Guest

    Messages:
    460
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Didn't I solve this problem in the other thread?
     
    MMJ, Jul 7, 2007 IP
  6. Luke Jones

    Luke Jones Peon

    Messages:
    427
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Yes, you did!
     
    Luke Jones, Jul 7, 2007 IP
  7. ansi

    ansi Well-Known Member

    Messages:
    1,483
    Likes Received:
    65
    Best Answers:
    0
    Trophy Points:
    100
    #7
    so is this solved or do you still need help?
     
    ansi, Jul 7, 2007 IP