Results 1 to 4 of 4
  1. #1
    Roll Tide mobilebadboy's Avatar
    Join Date
    January 18th, 2005
    Location
    Mobile, Alabama
    Posts
    1,220
    explode => delete => implode
    I really need some help with this. I'm building a portfolio system into a new site that I'm consolidating my day trading site in to. I have the company symbols stored in a pipe-delimited field. Example:

    MSFT|YHOO|DELL|AMZN

    So far I've been able to manipulate this data pretty well but now I've run into a roadblock. What I need to do is to, at any time, be able to individually delete one of those symbols and then group them all back together and update the database. So if I explode the string and want to remove DELL, it will end up with:

    MSFT|YHOO|AMZN

    Is there an easy way to go about this that I'm totally missing?

    Shawn Kerr (.com) | Disney World | SEC Football

  2. #2
    Moderator MichaelColey's Avatar
    Join Date
    January 18th, 2005
    Location
    Mansfield, TX
    Posts
    16,232
    It really depends on what programming language. Some make this easier than others.

    One trick that should be fairly easy in virtually any language is to add a | to the beginning and end, then replace |DELL| with |, then remove the leading and trailing |'s.

    For example:

    Step 1) MSFT|YHOO|DELL|AMZN -> |MSFT|YHOO|DELL|AMZN|
    Step 2) |MSFT|YHOO|DELL|AMZN| -> |MSFT|YHOO|AMZN|
    Step 3) |MSFT|YHOO|AMZN| -> MSFT|YHOO|AMZN
    Michael Coley
    Amazing-Bargains.com
     Affiliate Tips | Merchant Best Practices | Affiliate Friendly? | Couponing | CPA Networks? | ABW Tips | Activating Affiliates
    "Education is the most powerful weapon which you can use to change the world." Nelson Mandela

  3. #3
    Not Verif-Lidated infoTim's Avatar
    Join Date
    January 18th, 2005
    Location
    Sunny Florida
    Posts
    1,021
    In PHP, you can use the explode() function to break them apart into an array, use the unset() function to remove the element you don't want, then use impode() to put them back together into a string again with the pipe as a delimiter.
    Tim
    consultant by day, affiliate by night

  4. #4
    Roll Tide mobilebadboy's Avatar
    Join Date
    January 18th, 2005
    Location
    Mobile, Alabama
    Posts
    1,220
    unset()!! Just the function for what I need.

    Thanks guys.

    Shawn Kerr (.com) | Disney World | SEC Football

  5. Newsletter Signup

+ Reply to Thread

Similar Threads

  1. Replies: 11
    Last Post: March 9th, 2007, 11:31 AM
  2. Angelina's Lips Explode
    By bwc in forum Midnight Cafe'
    Replies: 22
    Last Post: December 20th, 2005, 08:18 AM
  3. Delete merchants, delete accounts
    By perfectG in forum Commission Junction - CJ
    Replies: 0
    Last Post: March 20th, 2003, 01:59 AM

Posting Permissions

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